[NOD-1303] Fix concurent access to UTXO set from RPC (#892)

This commit is contained in:
Ori Newman 2020-08-23 18:54:03 +03:00 committed by GitHub
parent a6b8eea369
commit 83e7c9e8e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -42,7 +42,7 @@ func (dag *BlockDAG) UTXOConfirmations(outpoint *appmessage.Outpoint) (uint64, b
dag.dagLock.RLock()
defer dag.dagLock.RUnlock()
utxoEntry, ok := dag.GetUTXOEntry(*outpoint)
utxoEntry, ok := dag.virtual.utxoSet.get(*outpoint)
if !ok {
return 0, false
}

View File

@ -248,6 +248,8 @@ func (dag *BlockDAG) CalcPastMedianTime() mstime.Time {
// This function is safe for concurrent access. However, the returned entry (if
// any) is NOT.
func (dag *BlockDAG) GetUTXOEntry(outpoint appmessage.Outpoint) (*UTXOEntry, bool) {
dag.RLock()
defer dag.RUnlock()
return dag.virtual.utxoSet.get(outpoint)
}