mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-19 14:29:27 +00:00
[release/1.4.10] core: solve a remote-import/local-mine data race
(cherry picked from commit f5a29eab5c)
This commit is contained in:
parent
f2e8759d10
commit
da776556d0
1 changed files with 3 additions and 4 deletions
|
|
@ -763,14 +763,13 @@ func (self *BlockChain) WriteBlock(block *types.Block) (status WriteStatus, err
|
||||||
if ptd == nil {
|
if ptd == nil {
|
||||||
return NonStatTy, ParentError(block.ParentHash())
|
return NonStatTy, ParentError(block.ParentHash())
|
||||||
}
|
}
|
||||||
|
|
||||||
localTd := self.GetTd(self.currentBlock.Hash())
|
|
||||||
externTd := new(big.Int).Add(block.Difficulty(), ptd)
|
|
||||||
|
|
||||||
// Make sure no inconsistent state is leaked during insertion
|
// Make sure no inconsistent state is leaked during insertion
|
||||||
self.mu.Lock()
|
self.mu.Lock()
|
||||||
defer self.mu.Unlock()
|
defer self.mu.Unlock()
|
||||||
|
|
||||||
|
localTd := self.GetTd(self.currentBlock.Hash())
|
||||||
|
externTd := new(big.Int).Add(block.Difficulty(), ptd)
|
||||||
|
|
||||||
// If the total difficulty is higher than our known, add it to the canonical chain
|
// If the total difficulty is higher than our known, add it to the canonical chain
|
||||||
// Second clause in the if statement reduces the vulnerability to selfish mining.
|
// Second clause in the if statement reduces the vulnerability to selfish mining.
|
||||||
// Please refer to http://www.cs.cornell.edu/~ie53/publications/btcProcFC.pdf
|
// Please refer to http://www.cs.cornell.edu/~ie53/publications/btcProcFC.pdf
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue