lntest: call markGraphSynced from gossipSyncer

Rather than performing this call in the SyncManager, we give each
gossipSyncer the ability to mark the first sync completed. This permits
pinned syncers to contribute towards the rpc-level synced_to_graph
value, allowing the value to be true after the first pinned syncer or
regular syncer complets. Unlinke regular syncers, pinned syncers can
proceed in parallel possibly decreasing the waiting time if consumers
rely on this field before proceeding to load their application.
This commit is contained in:
Conner Fromknecht
2021-01-29 00:14:50 -08:00
parent 920eda26fc
commit e42301dee2
4 changed files with 34 additions and 1 deletions

View File

@@ -280,6 +280,10 @@ type gossipSyncerCfg struct {
// bestHeight returns the latest height known of the chain.
bestHeight func() uint32
// markGraphSynced updates the SyncManager's perception of whether we
// have completed at least one historical sync.
markGraphSynced func()
// maxQueryChanRangeReplies is the maximum number of replies we'll allow
// for a single QueryChannelRange request.
maxQueryChanRangeReplies uint32
@@ -550,6 +554,11 @@ func (g *GossipSyncer) channelGraphSyncer() {
// to our terminal state.
g.setSyncState(chansSynced)
// Ensure that the sync manager becomes aware that the
// historical sync completed so synced_to_graph is
// updated over rpc.
g.cfg.markGraphSynced()
// In this state, we've just sent off a new query for channels
// that we don't yet know of. We'll remain in this state until
// the remote party signals they've responded to our query in
@@ -862,6 +871,11 @@ func (g *GossipSyncer) processChanRangeReply(msg *lnwire.ReplyChannelRange) erro
g.cfg.peerPub[:])
g.setSyncState(chansSynced)
// Ensure that the sync manager becomes aware that the
// historical sync completed so synced_to_graph is updated over
// rpc.
g.cfg.markGraphSynced()
return nil
}