From 83e7c9e8e41f0db553cb86f8d904e2ccad9f3d70 Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Sun, 23 Aug 2020 18:54:03 +0300 Subject: [PATCH] [NOD-1303] Fix concurent access to UTXO set from RPC (#892) --- domain/blockdag/confirmations.go | 2 +- domain/blockdag/dag.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/domain/blockdag/confirmations.go b/domain/blockdag/confirmations.go index b494ea490..37452441e 100644 --- a/domain/blockdag/confirmations.go +++ b/domain/blockdag/confirmations.go @@ -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 } diff --git a/domain/blockdag/dag.go b/domain/blockdag/dag.go index b7cfa706b..543727be2 100644 --- a/domain/blockdag/dag.go +++ b/domain/blockdag/dag.go @@ -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) }