diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-10-13 17:04:25 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-10-21 21:49:55 +0800 |
commit | 5b0ee8ec304663898073b7a4c659e1def23716df (patch) | |
tree | 8f2f49a8d26dc1c29e1d360fb787ab420d90a2ae /eth/sync.go | |
parent | aa0538db0b5de2bb2c609d629b65d083649f9171 (diff) | |
download | dexon-5b0ee8ec304663898073b7a4c659e1def23716df.tar dexon-5b0ee8ec304663898073b7a4c659e1def23716df.tar.gz dexon-5b0ee8ec304663898073b7a4c659e1def23716df.tar.bz2 dexon-5b0ee8ec304663898073b7a4c659e1def23716df.tar.lz dexon-5b0ee8ec304663898073b7a4c659e1def23716df.tar.xz dexon-5b0ee8ec304663898073b7a4c659e1def23716df.tar.zst dexon-5b0ee8ec304663898073b7a4c659e1def23716df.zip |
core, eth, trie: fix data races and merge/review issues
Diffstat (limited to 'eth/sync.go')
-rw-r--r-- | eth/sync.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/eth/sync.go b/eth/sync.go index 6295083e2..b69a24556 100644 --- a/eth/sync.go +++ b/eth/sync.go @@ -22,6 +22,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/p2p/discover" @@ -165,5 +166,20 @@ func (pm *ProtocolManager) synchronise(peer *peer) { return } // Otherwise try to sync with the downloader - pm.downloader.Synchronise(peer.id, peer.Head(), peer.Td()) + mode := downloader.FullSync + if pm.fastSync { + mode = downloader.FastSync + } + pm.downloader.Synchronise(peer.id, peer.Head(), peer.Td(), mode) + + // If fast sync was enabled, and we synced up, disable it + if pm.fastSync { + for pm.downloader.Synchronising() { + time.Sleep(100 * time.Millisecond) + } + if pm.blockchain.CurrentBlock().NumberU64() > 0 { + glog.V(logger.Info).Infof("fast sync complete, auto disabling") + pm.fastSync = false + } + } } |