mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[NOD-613] Fix concurrent access to ecmh cache (#565)
* [NOD-613] Fix concurrent access to ecmh cache. * [NOD-613] Localized dag.Lock().
This commit is contained in:
parent
d984151549
commit
e41d9866c3
@ -377,10 +377,14 @@ func (g *BlkTmplGenerator) UpdateExtraNonce(msgBlock *wire.MsgBlock, extraNonce
|
||||
hashMerkleTree := blockdag.BuildHashMerkleTreeStore(block.Transactions())
|
||||
msgBlock.Header.HashMerkleRoot = hashMerkleTree.Root()
|
||||
|
||||
utxoCommitment, err := g.buildUTXOCommitment(msgBlock.Transactions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// buildUTXOCommitment is the only function in UpdateExtraNonce that
|
||||
// requires the dagLock, and as such we lock and unlock it locally.
|
||||
utxoCommitment, err := func() (*daghash.Hash, error) {
|
||||
g.dag.Lock()
|
||||
defer g.dag.Unlock()
|
||||
|
||||
return g.buildUTXOCommitment(msgBlock.Transactions)
|
||||
}()
|
||||
|
||||
msgBlock.Header.UTXOCommitment = utxoCommitment
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user