mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-26 15:36:19 +01:00
Merge #19056: rpc: Make gettxoutsetinfo/GetUTXOStats interruptible
fa756928c3rpc: Make gettxoutsetinfo/GetUTXOStats interruptible (MarcoFalke)fa7fc5a8e0rpc: factor out RpcInterruptionPoint from dumptxoutset (MarcoFalke) Pull request description: Make it interruptible, so that shutdown doesn't block for up to one hour. Fixes (partially) #13217 ACKs for top commit: Empact: Code Review ACKfa756928c3laanwj: Code review ACKfa756928c3Tree-SHA512: 298261e0ff7d79fab542b8f6828cc0ac451cbafe396d5f0816c9d36437faba1330f5c4cb2a25c5540e202bfb9783da6ec858bd453056ce488d21e36335d3d42c
This commit is contained in:
@@ -33,7 +33,7 @@ static void ApplyStats(CCoinsStats &stats, CHashWriter& ss, const uint256& hash,
|
||||
}
|
||||
|
||||
//! Calculate statistics about the unspent transaction output set
|
||||
bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats)
|
||||
bool GetUTXOStats(CCoinsView* view, CCoinsStats& stats, const std::function<void()>& interruption_point)
|
||||
{
|
||||
stats = CCoinsStats();
|
||||
std::unique_ptr<CCoinsViewCursor> pcursor(view->Cursor());
|
||||
@@ -49,6 +49,7 @@ bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats)
|
||||
uint256 prevkey;
|
||||
std::map<uint32_t, Coin> outputs;
|
||||
while (pcursor->Valid()) {
|
||||
interruption_point();
|
||||
COutPoint key;
|
||||
Coin coin;
|
||||
if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <uint256.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
|
||||
class CCoinsView;
|
||||
|
||||
@@ -29,6 +30,6 @@ struct CCoinsStats
|
||||
};
|
||||
|
||||
//! Calculate statistics about the unspent transaction output set
|
||||
bool GetUTXOStats(CCoinsView* view, CCoinsStats& stats);
|
||||
bool GetUTXOStats(CCoinsView* view, CCoinsStats& stats, const std::function<void()>& interruption_point = {});
|
||||
|
||||
#endif // BITCOIN_NODE_COINSTATS_H
|
||||
|
||||
Reference in New Issue
Block a user