rpc: take ownership of the file by WriteUTXOSnapshot()

Have `WriteUTXOSnapshot()` take rvalue reference to make it obvious that
it takes ownership of the file.
This commit is contained in:
Hodlinator
2025-05-22 11:59:50 +02:00
committed by Vasil Dimov
parent 52e6e93c3f
commit a69c4098b2
3 changed files with 25 additions and 8 deletions

View File

@@ -47,8 +47,11 @@ CreateAndActivateUTXOSnapshot(
FILE* outfile{fsbridge::fopen(snapshot_path, "wb")};
AutoFile auto_outfile{outfile};
UniValue result = CreateUTXOSnapshot(
node, node.chainman->ActiveChainstate(), auto_outfile, snapshot_path, snapshot_path);
UniValue result = CreateUTXOSnapshot(node,
node.chainman->ActiveChainstate(),
std::move(auto_outfile), // Will close auto_outfile.
snapshot_path,
snapshot_path);
LogPrintf(
"Wrote UTXO snapshot to %s: %s\n", fs::PathToString(snapshot_path.make_preferred()), result.write());