discovery: remove channel synchronization from ActiveSync GossipSyncers

In this commit, we remove the ability for ActiveSync GossipSyncers to
synchronize our graph with our remote peers. This serves as a starting
point towards allowing the daemon to only synchronize our graph through
historical syncs, which will be routinely done by the SyncManager.
This commit is contained in:
Wilmer Paulino committed 2019-04-24 13:19:06 -07:00
1 parent 1c22474ad3
commit 9a6e8ecb9e
2 files changed
+16 -29

No files matched your search

+13 -14
View File
@@ -18,16 +18,23 @@ import (
type SyncerType uint8 type SyncerType uint8
const ( const (
// ActiveSync denotes that a gossip syncer should exercise its default // ActiveSync denotes that a gossip syncer:
// behavior. This includes reconciling the set of missing graph updates //
// with the remote peer _and_ receiving new updates from them. // 1. Should not attempt to synchronize with the remote peer for
// missing channels.
// 2. Should respond to queries from the remote peer.
// 3. Should receive new updates from the remote peer.
//
// They are started in a chansSynced state in order to accomplish their
// responsibilities above.
ActiveSync SyncerType = iota ActiveSync SyncerType = iota
// PassiveSync denotes that a gossip syncer: // PassiveSync denotes that a gossip syncer:
// //
// 1. Should not attempt to query the remote peer for graph updates. // 1. Should not attempt to synchronize with the remote peer for
// 2. Should respond to queries from the remote peer. // missing channels.
// 3. Should not receive new updates from the remote peer. // 2. Should respond to queries from the remote peer.
// 3. Should not receive new updates from the remote peer.
// //
// They are started in a chansSynced state in order to accomplish their // They are started in a chansSynced state in order to accomplish their
// responsibilities above. // responsibilities above.
@@ -1128,7 +1135,6 @@ func (g *GossipSyncer) handleSyncTransition(req *syncTransitionReq) error {
var ( var (
firstTimestamp time.Time firstTimestamp time.Time
timestampRange uint32 timestampRange uint32
newState syncerState
) )
switch req.newSyncType { switch req.newSyncType {
@@ -1137,11 +1143,6 @@ func (g *GossipSyncer) handleSyncTransition(req *syncTransitionReq) error {
case ActiveSync: case ActiveSync:
firstTimestamp = time.Now() firstTimestamp = time.Now()
timestampRange = math.MaxUint32 timestampRange = math.MaxUint32
newState = syncingChans
// We'll set genHistoricalChanRangeQuery to false since in order
// to not perform another historical sync if we previously have.
g.genHistoricalChanRangeQuery = false
// If a PassiveSync transition has been requested, then we should no // If a PassiveSync transition has been requested, then we should no
// longer receive any new updates from the remote peer. We can do this // longer receive any new updates from the remote peer. We can do this
@@ -1150,7 +1151,6 @@ func (g *GossipSyncer) handleSyncTransition(req *syncTransitionReq) error {
case PassiveSync: case PassiveSync:
firstTimestamp = zeroTimestamp firstTimestamp = zeroTimestamp
timestampRange = 0 timestampRange = 0
newState = chansSynced
default: default:
return fmt.Errorf("unhandled sync transition %v", return fmt.Errorf("unhandled sync transition %v",
@@ -1162,7 +1162,6 @@ func (g *GossipSyncer) handleSyncTransition(req *syncTransitionReq) error {
return fmt.Errorf("unable to send local update horizon: %v", err) return fmt.Errorf("unable to send local update horizon: %v", err)
} }
g.setSyncState(newState)
g.setSyncType(req.newSyncType) g.setSyncType(req.newSyncType)
return nil return nil
+3 -15
View File
@@ -2014,8 +2014,7 @@ func TestGossipSyncerSyncTransitions(t *testing.T) {
syncState := g.syncState() syncState := g.syncState()
if syncState != chansSynced { if syncState != chansSynced {
t.Fatalf("expected syncerState %v, "+ t.Fatalf("expected syncerState %v, "+
"got %v", chansSynced, "got %v", chansSynced, syncState)
syncState)
} }
}, },
}, },
@@ -2037,21 +2036,10 @@ func TestGossipSyncerSyncTransitions(t *testing.T) {
TimestampRange: math.MaxUint32, TimestampRange: math.MaxUint32,
}) })
// The local update horizon should be followed
// by a QueryChannelRange message sent to the
// remote peer requesting all channels it
// knows of from the highest height the syncer
// knows of.
assertMsgSent(t, msgChan, &lnwire.QueryChannelRange{
FirstBlockHeight: startHeight,
NumBlocks: math.MaxUint32 - startHeight,
})
syncState := g.syncState() syncState := g.syncState()
if syncState != waitingQueryRangeReply { if syncState != chansSynced {
t.Fatalf("expected syncerState %v, "+ t.Fatalf("expected syncerState %v, "+
"got %v", waitingQueryRangeReply, "got %v", chansSynced, syncState)
syncState)
} }
}, },
}, },