56
56
#include < condition_variable>
57
57
#include < memory>
58
58
#include < mutex>
59
+ #include < optional>
59
60
60
61
using kernel::CCoinsStats;
61
62
using kernel::CoinStatsHashType;
@@ -2786,8 +2787,8 @@ static RPCHelpMan dumptxoutset()
2786
2787
2787
2788
CConnman& connman = EnsureConnman (node);
2788
2789
const CBlockIndex* invalidate_index{nullptr };
2789
- std::unique_ptr <NetworkDisable> disable_network;
2790
- std::unique_ptr <TemporaryRollback> temporary_rollback;
2790
+ std::optional <NetworkDisable> disable_network;
2791
+ std::optional <TemporaryRollback> temporary_rollback;
2791
2792
2792
2793
// If the user wants to dump the txoutset of the current tip, we don't have
2793
2794
// to roll back at all
@@ -2812,18 +2813,16 @@ static RPCHelpMan dumptxoutset()
2812
2813
// automatically re-enables the network activity at the end of the
2813
2814
// process which may not be what the user wants.
2814
2815
if (connman.GetNetworkActive ()) {
2815
- disable_network = std::make_unique<NetworkDisable> (connman);
2816
+ disable_network. emplace (connman);
2816
2817
}
2817
2818
2818
2819
invalidate_index = WITH_LOCK (::cs_main, return node.chainman ->ActiveChain ().Next (target_index));
2819
- temporary_rollback = std::make_unique<TemporaryRollback> (*node.chainman , *invalidate_index);
2820
+ temporary_rollback. emplace (*node.chainman , *invalidate_index);
2820
2821
}
2821
2822
2822
2823
Chainstate* chainstate;
2823
2824
std::unique_ptr<CCoinsViewCursor> cursor;
2824
2825
CCoinsStats stats;
2825
- UniValue result;
2826
- UniValue error;
2827
2826
{
2828
2827
// Lock the chainstate before calling PrepareUtxoSnapshot, to be able
2829
2828
// to get a UTXO database cursor while the chain is pointing at the
@@ -2847,7 +2846,7 @@ static RPCHelpMan dumptxoutset()
2847
2846
}
2848
2847
}
2849
2848
2850
- result = WriteUTXOSnapshot (*chainstate, cursor.get (), &stats, tip, afile, path, temppath, node.rpc_interruption_point );
2849
+ UniValue result = WriteUTXOSnapshot (*chainstate, cursor.get (), &stats, tip, afile, path, temppath, node.rpc_interruption_point );
2851
2850
fs::rename (temppath, path);
2852
2851
2853
2852
result.pushKV (" path" , path.utf8string ());
0 commit comments