Skip to content

Commit 584ae3b

Browse files
committed
feat: assumeutxo: enable loading snapshot in memory
1 parent 6f1d906 commit 584ae3b

File tree

3 files changed

+8336
-2
lines changed

3 files changed

+8336
-2
lines changed

src/rpc/blockchain.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,6 +2750,10 @@ static RPCHelpMan loadtxoutset()
27502750
RPCArg::Type::STR,
27512751
RPCArg::Optional::NO,
27522752
"path to the snapshot file. If relative, will be prefixed by datadir."},
2753+
{"in_memory",
2754+
RPCArg::Type::BOOL,
2755+
RPCArg::Optional::OMITTED,
2756+
"should we load snapshot in memory."}
27532757
},
27542758
RPCResult{
27552759
RPCResult::Type::OBJ, "", "",
@@ -2761,13 +2765,15 @@ static RPCHelpMan loadtxoutset()
27612765
}
27622766
},
27632767
RPCExamples{
2764-
HelpExampleCli("loadtxoutset", "utxo.dat")
2768+
HelpExampleCli("loadtxoutset", "utxo.dat") +
2769+
HelpExampleCli("dumptxoutset", "\"utxo.dat\" \"true\""),
27652770
},
27662771
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
27672772
{
27682773
NodeContext& node = EnsureAnyNodeContext(request.context);
27692774
ChainstateManager& chainman = EnsureChainman(node);
27702775
fs::path path{AbsPathForConfigVal(EnsureArgsman(node), fs::u8path(request.params[0].get_str()))};
2776+
bool in_memory{request.params[1].isNull() ? false : request.params[1].get_bool()};
27712777

27722778
FILE* file{fsbridge::fopen(path, "rb")};
27732779
AutoFile afile{file};
@@ -2794,7 +2800,7 @@ static RPCHelpMan loadtxoutset()
27942800
strprintf("The base block header (%s) must appear in the headers chain. Make sure all headers are syncing, and call this RPC again.",
27952801
base_blockhash.ToString()));
27962802
}
2797-
if (!chainman.ActivateSnapshot(afile, metadata, false)) {
2803+
if (!chainman.ActivateSnapshot(afile, metadata, in_memory)) {
27982804
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to load UTXO snapshot " + fs::PathToString(path));
27992805
}
28002806

0 commit comments

Comments
 (0)