rpc: make `gettxoutsettinfo` run lock-free
For leveldb "An iterator operates on a snapshot of the database taken when the iterator is created". This means that it is unnecessary to lock out other threads while computing statistics, and neither to hold cs_main for the whole time. Let the thread run free.
This commit is contained in:
parent
cbf3ab51f9
commit
a0455eca11
|
@ -367,8 +367,6 @@ UniValue gettxoutsetinfo(const UniValue& params, bool fHelp)
|
|||
+ HelpExampleRpc("gettxoutsetinfo", "")
|
||||
);
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
UniValue ret(UniValue::VOBJ);
|
||||
|
||||
CCoinsStats stats;
|
||||
|
|
|
@ -225,7 +225,10 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) const {
|
|||
return error("%s: Deserialize or I/O error - %s", __func__, e.what());
|
||||
}
|
||||
}
|
||||
stats.nHeight = mapBlockIndex.find(GetBestBlock())->second->nHeight;
|
||||
{
|
||||
LOCK(cs_main);
|
||||
stats.nHeight = mapBlockIndex.find(stats.hashBlock)->second->nHeight;
|
||||
}
|
||||
stats.hashSerialized = ss.GetHash();
|
||||
stats.nTotalAmount = nTotalAmount;
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue