Update checkBIP0030 to not use deprecated function.

Rather than using the deprecated TxShas function on a btcutil.Block,
convert the checkBIP0030 to use the newer preferred method of ranging over
the Transactions to obtain the cached hash of each transaction.

This is also a little more efficient since it can avoid creating and
caching an extra slice to keep the hashes in addition to having the hash
cached with each transaction.
This commit is contained in:
Dave Collins 2014-03-24 13:14:04 -05:00
parent 96f9b88935
commit 67ebfa0e80

View file

@ -552,13 +552,9 @@ func isTransactionSpent(txD *TxData) bool {
func (b *BlockChain) checkBIP0030(node *blockNode, block *btcutil.Block) error { func (b *BlockChain) checkBIP0030(node *blockNode, block *btcutil.Block) error {
// Attempt to fetch duplicate transactions for all of the transactions // Attempt to fetch duplicate transactions for all of the transactions
// in this block from the point of view of the parent node. // in this block from the point of view of the parent node.
fetchList, err := block.TxShas()
if err != nil {
return nil
}
fetchSet := make(map[btcwire.ShaHash]bool) fetchSet := make(map[btcwire.ShaHash]bool)
for _, txHash := range fetchList { for _, tx := range block.Transactions() {
fetchSet[*txHash] = true fetchSet[*tx.Sha()] = true
} }
txResults, err := b.fetchTxStore(node, fetchSet) txResults, err := b.fetchTxStore(node, fetchSet)
if err != nil { if err != nil {