aboutsummaryrefslogtreecommitdiffstats
path: root/eth/sync.go
diff options
context:
space:
mode:
authorZsolt Felfoldi <zsfelfoldi@gmail.com>2016-12-09 16:03:22 +0800
committerZsolt Felfoldi <zsfelfoldi@gmail.com>2016-12-10 16:53:25 +0800
commitc57c54ce96628aeb6345776310123a80593f0143 (patch)
tree1d590f2f0aee32179a57eba5a4886f4296ab1196 /eth/sync.go
parentc8130df1d9dcc504244a49cbb12aa4c2848e5de2 (diff)
downloadgo-tangerine-c57c54ce96628aeb6345776310123a80593f0143.tar
go-tangerine-c57c54ce96628aeb6345776310123a80593f0143.tar.gz
go-tangerine-c57c54ce96628aeb6345776310123a80593f0143.tar.bz2
go-tangerine-c57c54ce96628aeb6345776310123a80593f0143.tar.lz
go-tangerine-c57c54ce96628aeb6345776310123a80593f0143.tar.xz
go-tangerine-c57c54ce96628aeb6345776310123a80593f0143.tar.zst
go-tangerine-c57c54ce96628aeb6345776310123a80593f0143.zip
eth, les: defer starting LES service until ETH initial sync is finished
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 6584bb1e2..b6918c2be 100644
--- a/eth/sync.go
+++ b/eth/sync.go
@@ -180,7 +180,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 {
@@ -191,3 +191,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()
+ }
+}