Fix a potential issue with removing orphan blocks.
The range loop is over a local var, so the local variable needs to be updated and then set back into the chain instance after the range loop.
This commit is contained in:
parent
0c2d4435ca
commit
c00de3ffd5
1 changed files with 2 additions and 1 deletions
3
chain.go
3
chain.go
|
@ -194,9 +194,10 @@ func (b *BlockChain) removeOrphanBlock(orphan *orphanBlock) {
|
|||
if hash.IsEqual(orphanHash) {
|
||||
copy(orphans[i:], orphans[i+1:])
|
||||
orphans[len(orphans)-1] = nil
|
||||
b.prevOrphans[*prevHash] = orphans[:len(orphans)-1]
|
||||
orphans = orphans[:len(orphans)-1]
|
||||
}
|
||||
}
|
||||
b.prevOrphans[*prevHash] = orphans
|
||||
|
||||
// Remove the map entry altogether if there are no longer any orphans
|
||||
// which depend on the parent hash.
|
||||
|
|
Loading…
Reference in a new issue