discovery: add new SyncState method to gossipSyncer

This new method allows outside callers to sample the current state of
the gossipSyncer in a concurrent-safe manner. In order to achieve this,
we now only modify the g.state variable atomically.
This commit is contained in:
Olaoluwa Osuntokun committed 2018-05-31 16:31:00 -07:00
1 parent 70dffe7e99
commit 6a6700e629
2 files changed
+21 -13

No files matched your search

+2 -2
View File
@@ -834,7 +834,7 @@ func TestGossipSyncerProcessChanRangeReply(t *testing.T) {
t.Fatalf("unable to process reply: %v", err)
}
if syncer.state != queryNewChannels {
if syncer.SyncState() != queryNewChannels {
t.Fatalf("wrong state: expected %v instead got %v",
queryNewChannels, syncer.state)
}
@@ -867,7 +867,7 @@ func TestGossipSyncerProcessChanRangeReply(t *testing.T) {
t.Fatalf("unable to process reply: %v", err)
}
if syncer.state != chansSynced {
if syncer.SyncState() != chansSynced {
t.Fatalf("wrong state: expected %v instead got %v",
chansSynced, syncer.state)
}