From c00de3ffd579b2591dba65af6b1225ecd8e5132e Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sun, 4 Aug 2013 13:41:05 -0500 Subject: [PATCH] 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. --- chain.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chain.go b/chain.go index 04617efbd..d68463bdb 100644 --- a/chain.go +++ b/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.