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:
Dave Collins 2013-08-04 13:41:05 -05:00
parent 0c2d4435ca
commit c00de3ffd5

View file

@ -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.