-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
discovery+graph: track job set dependencies in vb #9241
Open
Crypt-iQ
wants to merge
4
commits into
lightningnetwork:master
Choose a base branch
from
Crypt-iQ:fix_vb
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+499
−213
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e66fb21
graph: change ValidationBarrier usage in the router
Crypt-iQ 55834fd
fn: add Empty to Set and bump go mod
Crypt-iQ b721488
discovery+graph: track job set dependencies in ValidationBarrier
Crypt-iQ c5e584a
release-notes: update for 0.19.0
Crypt-iQ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,6 @@ import ( | |
"fmt" | ||
"sync" | ||
|
||
"github.com/lightningnetwork/lnd/channeldb" | ||
"github.com/lightningnetwork/lnd/channeldb/models" | ||
"github.com/lightningnetwork/lnd/lnwire" | ||
"github.com/lightningnetwork/lnd/routing/route" | ||
) | ||
|
@@ -80,6 +78,18 @@ func NewValidationBarrier(numActiveReqs int, | |
return v | ||
} | ||
|
||
// FetchJobSlot fetches a job slot. This is only used in the graph/builder.go | ||
// code since it needs to use the sempahore and no other ValidationBarrier | ||
// functionality. | ||
func (v *ValidationBarrier) FetchJobSlot() { | ||
// We'll wait for either a new slot to become open, or for the quit | ||
Comment on lines
+93
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since the builder code is called by the gossiper code which itself also uses a semaphore - why isnt that inheritance enough? |
||
// channel to be closed. | ||
select { | ||
case <-v.validationSemaphore: | ||
case <-v.quit: | ||
} | ||
} | ||
|
||
// InitJobDependencies will wait for a new job slot to become open, and then | ||
// sets up any dependent signals/trigger for the new job | ||
func (v *ValidationBarrier) InitJobDependencies(job interface{}) { | ||
|
@@ -126,33 +136,14 @@ func (v *ValidationBarrier) InitJobDependencies(job interface{}) { | |
v.nodeAnnDependencies[route.Vertex(msg.NodeID1)] = signals | ||
v.nodeAnnDependencies[route.Vertex(msg.NodeID2)] = signals | ||
} | ||
case *models.ChannelEdgeInfo: | ||
|
||
shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID) | ||
if _, ok := v.chanAnnFinSignal[shortID]; !ok { | ||
signals := &validationSignals{ | ||
allow: make(chan struct{}), | ||
deny: make(chan struct{}), | ||
} | ||
|
||
v.chanAnnFinSignal[shortID] = signals | ||
v.chanEdgeDependencies[shortID] = signals | ||
|
||
v.nodeAnnDependencies[route.Vertex(msg.NodeKey1Bytes)] = signals | ||
v.nodeAnnDependencies[route.Vertex(msg.NodeKey2Bytes)] = signals | ||
} | ||
|
||
// These other types don't have any dependants, so no further | ||
// initialization needs to be done beyond just occupying a job slot. | ||
case *models.ChannelEdgePolicy: | ||
return | ||
case *lnwire.ChannelUpdate1: | ||
return | ||
case *lnwire.NodeAnnouncement: | ||
// TODO(roasbeef): node ann needs to wait on existing channel updates | ||
return | ||
case *channeldb.LightningNode: | ||
return | ||
case *lnwire.AnnounceSignatures1: | ||
// TODO(roasbeef): need to wait on chan ann? | ||
return | ||
|
@@ -188,20 +179,6 @@ func (v *ValidationBarrier) WaitForDependants(job interface{}) error { | |
switch msg := job.(type) { | ||
// Any ChannelUpdate or NodeAnnouncement jobs will need to wait on the | ||
// completion of any active ChannelAnnouncement jobs related to them. | ||
case *models.ChannelEdgePolicy: | ||
shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID) | ||
signals, ok = v.chanEdgeDependencies[shortID] | ||
|
||
jobDesc = fmt.Sprintf("job=lnwire.ChannelEdgePolicy, scid=%v", | ||
msg.ChannelID) | ||
|
||
case *channeldb.LightningNode: | ||
vertex := route.Vertex(msg.PubKeyBytes) | ||
signals, ok = v.nodeAnnDependencies[vertex] | ||
|
||
jobDesc = fmt.Sprintf("job=channeldb.LightningNode, pub=%s", | ||
vertex) | ||
|
||
case *lnwire.ChannelUpdate1: | ||
signals, ok = v.chanEdgeDependencies[msg.ShortChannelID] | ||
|
||
|
@@ -218,7 +195,6 @@ func (v *ValidationBarrier) WaitForDependants(job interface{}) error { | |
// return directly. | ||
case *lnwire.AnnounceSignatures1: | ||
// TODO(roasbeef): need to wait on chan ann? | ||
case *models.ChannelEdgeInfo: | ||
case *lnwire.ChannelAnnouncement1: | ||
} | ||
|
||
|
@@ -264,17 +240,6 @@ func (v *ValidationBarrier) SignalDependants(job interface{}, allow bool) { | |
// If we've just finished executing a ChannelAnnouncement, then we'll | ||
// close out the signal, and remove the signal from the map of active | ||
// ones. This will allow/deny any dependent jobs to continue execution. | ||
case *models.ChannelEdgeInfo: | ||
shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID) | ||
finSignals, ok := v.chanAnnFinSignal[shortID] | ||
if ok { | ||
if allow { | ||
close(finSignals.allow) | ||
} else { | ||
close(finSignals.deny) | ||
} | ||
delete(v.chanAnnFinSignal, shortID) | ||
} | ||
case *lnwire.ChannelAnnouncement1: | ||
finSignals, ok := v.chanAnnFinSignal[msg.ShortChannelID] | ||
if ok { | ||
|
@@ -291,15 +256,10 @@ func (v *ValidationBarrier) SignalDependants(job interface{}, allow bool) { | |
// For all other job types, we'll delete the tracking entries from the | ||
// map, as if we reach this point, then all dependants have already | ||
// finished executing and we can proceed. | ||
case *channeldb.LightningNode: | ||
delete(v.nodeAnnDependencies, route.Vertex(msg.PubKeyBytes)) | ||
case *lnwire.NodeAnnouncement: | ||
delete(v.nodeAnnDependencies, route.Vertex(msg.NodeID)) | ||
case *lnwire.ChannelUpdate1: | ||
delete(v.chanEdgeDependencies, msg.ShortChannelID) | ||
case *models.ChannelEdgePolicy: | ||
shortID := lnwire.NewShortChanIDFromInt(msg.ChannelID) | ||
delete(v.chanEdgeDependencies, shortID) | ||
|
||
case *lnwire.AnnounceSignatures1: | ||
return | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit title nit: this is not the
router
, it's thegraph.Builder