From b557a33f7ce0ce59a02f6c308de44dba137f9e62 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Mon, 9 Sep 2013 19:35:36 -0500 Subject: [PATCH] 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. --- notifications.go | 5 +++-- process.go | 7 ++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/notifications.go b/notifications.go index bd3dfe9a..4ad7b376 100644 --- a/notifications.go +++ b/notifications.go @@ -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 diff --git a/process.go b/process.go index 29aaa0bf..98e120f4 100644 --- a/process.go +++ b/process.go @@ -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 }