Send orphan hash in notifications instead of root.

Rather than sending the root of the an orphan chain when sending an orphan
notification, send the hash of the orphan block itself.  The caller can
then call the GetOrphanRoot function with the hash to get the root of the
orphan chain as needed.  This is being changed since it's cleaner and more
detministic sending the hash for the orphan block that was just processed
rather than sending a possibly different hash depending on whether there
is an orphan chain or not.
This commit is contained in:
Dave Collins 2013-09-09 19:35:36 -05:00
parent 0ba8cb9187
commit b557a33f7c
2 changed files with 5 additions and 7 deletions

View File

@ -14,8 +14,9 @@ type NotificationType int
// Constants for the type of a notification message.
const (
// NTOrphanBlock indicates an orphan block was processed and the
// associated block hash is the root of all known orphans which should
// be used to request the missing blocks.
// associated block hash should be passed to the GetOrphanRoot function
// to find the root of all known orphans which should then be used to
// request the missing blocks.
NTOrphanBlock NotificationType = iota
// NTBlockAccepted indicates the associated block was accepted into

View File

@ -148,11 +148,8 @@ func (b *BlockChain) ProcessBlock(block *btcutil.Block) error {
prevHash)
b.addOrphanBlock(block)
// 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(blockHash)
b.sendNotification(NTOrphanBlock, orphanRoot)
// Notify the caller so it can request missing blocks.
b.sendNotification(NTOrphanBlock, blockHash)
return nil
}