diff --git a/chain.go b/chain.go index c02a9199..b69dafe6 100644 --- a/chain.go +++ b/chain.go @@ -168,19 +168,21 @@ func (b *BlockChain) DisableVerify(disable bool) { // getOrphanRoot returns the head of the chain for the provided hash from the // map of orphan blocks. -func (b *BlockChain) getOrphanRoot(sha *btcwire.ShaHash) *btcwire.ShaHash { +func (b *BlockChain) getOrphanRoot(hash *btcwire.ShaHash) *btcwire.ShaHash { // Keep looping while the parent of each orphaned block is // known and is an orphan itself. - prevHash := sha + orphanRoot := hash + prevHash := hash for { orphan, exists := b.orphans[*prevHash] if !exists { break } + orphanRoot = prevHash prevHash = &orphan.block.MsgBlock().Header.PrevBlock } - return prevHash + return orphanRoot } // removeOrphanBlock removes the passed orphan block from the orphan pool and diff --git a/process.go b/process.go index 876dc330..b608635a 100644 --- a/process.go +++ b/process.go @@ -151,7 +151,7 @@ func (b *BlockChain) ProcessBlock(block *btcutil.Block) error { // Get the hash for the head of the orphaned block chain for // this block and notify the caller so it can request missing // blocks. - orphanRoot := b.getOrphanRoot(prevHash) + orphanRoot := b.getOrphanRoot(blockHash) b.sendNotification(NTOrphanBlock, orphanRoot) return nil }