discovery: perform initial historical sync for pinned peers
This commit is contained in:
parent
2f0d56d539
commit
340414356d
@ -266,7 +266,9 @@ func (m *SyncManager) syncerHandler() {
|
|||||||
// For pinned syncers, we will immediately transition
|
// For pinned syncers, we will immediately transition
|
||||||
// the peer into an active (pinned) sync state.
|
// the peer into an active (pinned) sync state.
|
||||||
case isPinnedSyncer:
|
case isPinnedSyncer:
|
||||||
|
attemptHistoricalSync = true
|
||||||
s.setSyncType(PinnedSync)
|
s.setSyncType(PinnedSync)
|
||||||
|
s.setSyncState(syncerIdle)
|
||||||
m.pinnedActiveSyncers[s.cfg.peerPub] = s
|
m.pinnedActiveSyncers[s.cfg.peerPub] = s
|
||||||
|
|
||||||
// Regardless of whether the initial historical sync
|
// Regardless of whether the initial historical sync
|
||||||
@ -331,7 +333,9 @@ func (m *SyncManager) syncerHandler() {
|
|||||||
// keep track of the corresponding syncer to properly
|
// keep track of the corresponding syncer to properly
|
||||||
// handle disconnects. We'll also use a signal to know
|
// handle disconnects. We'll also use a signal to know
|
||||||
// when the historical sync completed.
|
// when the historical sync completed.
|
||||||
|
if !isPinnedSyncer {
|
||||||
setInitialHistoricalSyncer(s)
|
setInitialHistoricalSyncer(s)
|
||||||
|
}
|
||||||
|
|
||||||
// An existing peer has disconnected, so we'll tear down its
|
// An existing peer has disconnected, so we'll tear down its
|
||||||
// corresponding GossipSyncer.
|
// corresponding GossipSyncer.
|
||||||
|
@ -90,6 +90,8 @@ func TestSyncManagerNumActiveSyncers(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s := assertSyncerExistence(t, syncMgr, peer)
|
s := assertSyncerExistence(t, syncMgr, peer)
|
||||||
|
assertTransitionToChansSynced(t, s, peer)
|
||||||
|
assertActiveGossipTimestampRange(t, peer)
|
||||||
assertSyncerStatus(t, s, chansSynced, PinnedSync)
|
assertSyncerStatus(t, s, chansSynced, PinnedSync)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +115,12 @@ const (
|
|||||||
// AuthenticatedGossiper, and decide if we should forward them to our
|
// AuthenticatedGossiper, and decide if we should forward them to our
|
||||||
// target peer based on its update horizon.
|
// target peer based on its update horizon.
|
||||||
chansSynced
|
chansSynced
|
||||||
|
|
||||||
|
// syncerIdle is a state in which the gossip syncer can handle external
|
||||||
|
// requests to transition or perform historical syncs. It is used as the
|
||||||
|
// initial state for pinned syncers, as well as a fallthrough case for
|
||||||
|
// chansSynced allowing fully synced peers to facilitate requests.
|
||||||
|
syncerIdle
|
||||||
)
|
)
|
||||||
|
|
||||||
// String returns a human readable string describing the target syncerState.
|
// String returns a human readable string describing the target syncerState.
|
||||||
@ -135,6 +141,9 @@ func (s syncerState) String() string {
|
|||||||
case chansSynced:
|
case chansSynced:
|
||||||
return "chansSynced"
|
return "chansSynced"
|
||||||
|
|
||||||
|
case syncerIdle:
|
||||||
|
return "syncerIdle"
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "UNKNOWN STATE"
|
return "UNKNOWN STATE"
|
||||||
}
|
}
|
||||||
@ -592,10 +601,16 @@ func (g *GossipSyncer) channelGraphSyncer() {
|
|||||||
g.cfg.peerPub, err)
|
g.cfg.peerPub, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// With our horizon set, we'll simply reply to any new
|
// With our horizon set, we'll simply reply to any new
|
||||||
// messages or process any state transitions and exit if
|
// messages or process any state transitions and exit if
|
||||||
// needed.
|
// needed.
|
||||||
|
fallthrough
|
||||||
|
|
||||||
|
// Pinned peers will begin in this state, since they will
|
||||||
|
// immediately receive a request to perform a historical sync.
|
||||||
|
// Otherwise, we fall through after ending in chansSynced to
|
||||||
|
// facilitate new requests.
|
||||||
|
case syncerIdle:
|
||||||
select {
|
select {
|
||||||
case req := <-g.syncTransitionReqs:
|
case req := <-g.syncTransitionReqs:
|
||||||
req.errChan <- g.handleSyncTransition(req)
|
req.errChan <- g.handleSyncTransition(req)
|
||||||
|
Loading…
Reference in New Issue
Block a user