Skip to content

Commit

Permalink
client/asset/btc: use known block hash
Browse files Browse the repository at this point in the history
Use the known block Hash instead of using the btcutil.(*Block).Hash
method.  That method mutates a field of the Block to cache the hash,
unfortunately it is not thread-safe, and it is unuse confurrent with
other goroutines inside neutrino including VerifyBasicBlockFilter.
  • Loading branch information
chappjc committed Nov 11, 2021
1 parent 6acc21f commit 4249d97
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client/asset/btc/spv.go
Expand Up @@ -1407,7 +1407,7 @@ search:
res.spend = &spendingInput{
txHash: tx.TxHash(),
vin: uint32(vin),
blockHash: *block.Hash(),
blockHash: *blockHash,
blockHeight: uint32(height),
}
w.log.Tracef("Found txn %v spending %v in block %v (%d)", res.spend.txHash,
Expand All @@ -1427,7 +1427,7 @@ search:
}
for _, txOut := range tx.TxOut {
if bytes.Equal(txOut.PkScript, pkScript) {
res.blockHash = block.Hash()
res.blockHash = blockHash
res.blockHeight = uint32(height)
res.txOut = txOut
w.log.Tracef("Found txn %v in block %v (%d)", txHash, res.blockHash, height)
Expand Down

0 comments on commit 4249d97

Please sign in to comment.