mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
Merge 18075407c9 into 6d1e292eef
This commit is contained in:
commit
7ce7c8effe
2 changed files with 4 additions and 3 deletions
|
|
@ -107,7 +107,6 @@ type BlockChain struct {
|
|||
chainmu sync.RWMutex // blockchain insertion lock
|
||||
procmu sync.RWMutex // block processor lock
|
||||
|
||||
checkpoint int // checkpoint counts towards the new checkpoint
|
||||
currentBlock atomic.Value // Current head of the block chain
|
||||
currentFastBlock atomic.Value // Current head of the fast-sync chain (may be above the block chain!)
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
|
|||
td := pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64())
|
||||
|
||||
pHead, pTd := peer.Head()
|
||||
if pTd.Cmp(td) <= 0 {
|
||||
if pTd == nil || pTd.Cmp(td) <= 0 {
|
||||
return
|
||||
}
|
||||
// Otherwise try to sync with the downloader
|
||||
|
|
@ -190,8 +190,10 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
|
|||
}
|
||||
|
||||
if mode == downloader.FastSync {
|
||||
currentFastBlock := pm.blockchain.CurrentFastBlock()
|
||||
fastTd := pm.blockchain.GetTd(currentFastBlock.Hash(), currentFastBlock.NumberU64())
|
||||
// Make sure the peer's total difficulty we are synchronizing is higher.
|
||||
if pm.blockchain.GetTdByHash(pm.blockchain.CurrentFastBlock().Hash()).Cmp(pTd) >= 0 {
|
||||
if pTd.Cmp(fastTd) <= 0 {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue