Send orphan root in notifies instead of its parent.
The notification for orphan blocks was sending the parent of orphan root instead of the orphan root itself.
This commit is contained in:
parent
2835238287
commit
f4bae7dc41
2 changed files with 6 additions and 4 deletions
8
chain.go
8
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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue