aboutsummaryrefslogtreecommitdiffstats
path: root/eth/sync.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2016-12-13 03:46:15 +0800
committerGitHub <noreply@github.com>2016-12-13 03:46:15 +0800
commita98e8c0889d7c4c1bded452c577bd4b9c7fa0f6b (patch)
treefaccd87d6e1634b51f788fa170bc1f03a829ca42 /eth/sync.go
parentee445a2ba4013f8b32e4e5386322babf022e5b81 (diff)
parentf12f8a6c14dbaf6e6531cea1b0cf169b851e1894 (diff)
downloaddexon-a98e8c0889d7c4c1bded452c577bd4b9c7fa0f6b.tar
dexon-a98e8c0889d7c4c1bded452c577bd4b9c7fa0f6b.tar.gz
dexon-a98e8c0889d7c4c1bded452c577bd4b9c7fa0f6b.tar.bz2
dexon-a98e8c0889d7c4c1bded452c577bd4b9c7fa0f6b.tar.lz
dexon-a98e8c0889d7c4c1bded452c577bd4b9c7fa0f6b.tar.xz
dexon-a98e8c0889d7c4c1bded452c577bd4b9c7fa0f6b.tar.zst
dexon-a98e8c0889d7c4c1bded452c577bd4b9c7fa0f6b.zip
Merge pull request #3413 from zsfelfoldi/light-topic4
les, p2p/discv5: implement server pool, improve peer selection, light fetcher and topic searching
Diffstat (limited to 'eth/sync.go')
-rw-r--r--eth/sync.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/eth/sync.go b/eth/sync.go
index 373cc2054..234534b4f 100644
--- a/eth/sync.go
+++ b/eth/sync.go
@@ -181,7 +181,7 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
if err := pm.downloader.Synchronise(peer.id, pHead, pTd, mode); err != nil {
return
}
- atomic.StoreUint32(&pm.synced, 1) // Mark initial sync done
+ pm.setSynced() // Mark initial sync done
// If fast sync was enabled, and we synced up, disable it
if atomic.LoadUint32(&pm.fastSync) == 1 {
@@ -192,3 +192,10 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
}
}
}
+
+// setSynced sets the synced flag and notifies the light server if present
+func (pm *ProtocolManager) setSynced() {
+ if atomic.SwapUint32(&pm.synced, 1) == 0 && pm.lesServer != nil {
+ pm.lesServer.Synced()
+ }
+}