diff --git a/chain.go b/chain.go index 9441b1fc..4e396ce7 100644 --- a/chain.go +++ b/chain.go @@ -167,38 +167,13 @@ func (b *BlockChain) DisableVerify(disable bool) { b.noVerify = disable } -// HaveInventory returns whether or not the chain instance has the inventory -// represented by the passed inventory vector. This includes checking all of -// the various places inventory can be when it is in different states such as -// part of the main chain, on a side chain, and orphans. +// HaveBlock returns whether or not the chain instance has the block represented +// by the passed hash. This includes checking the various places a block can +// be like part of the main chain, on a side chain, or in the orphan pool. // -// This function is safe for concurrent access. -func (b *BlockChain) HaveInventory(inventoryVector *btcwire.InvVect) bool { - switch inventoryVector.Type { - case btcwire.InvVect_Block: - // Check the main chain and side chains. - if b.blockExists(&inventoryVector.Hash) { - return true - } - - // Check orphan blocks. - if b.IsKnownOrphan(&inventoryVector.Hash) { - return true - } - - case btcwire.InvVect_Tx: - // TODO(davec): Need to ultimately maintain a transaction pool - // of transactions that are not already in a block and check - // for the existing transaction there too. - - // Check if the transaction exists from the point of view of the - // end of the main chain. - return b.db.ExistsTxSha(&inventoryVector.Hash) - } - - // The requested inventory is either not known or is an unsupported - // type (which also implies it is not known). - return false +// This function is NOT safe for concurrent access. +func (b *BlockChain) HaveBlock(hash *btcwire.ShaHash) bool { + return b.IsKnownOrphan(hash) && b.blockExists(hash) } // IsKnownOrphan returns whether the passed hash is currently a known orphan.