diff options
author | stickies-v <stickies-v@protonmail.com> | 2022-10-09 17:19:06 +0100 |
---|---|---|
committer | stickies-v <stickies-v@protonmail.com> | 2022-12-13 15:42:49 +0000 |
commit | f911bdfff95eba3793fffaf71a31cc8bfc6f80c9 (patch) | |
tree | 3ea4d4ae42f038409ccf60af7e7c267bcc1305fa /src/rpc | |
parent | 66e028f7399b6511f9b73b1cef54b6a6ac38a024 (diff) |
mempool: use util::Result for CalculateMemPoolAncestors
Avoid using setAncestors outparameter, simplify function signatures
and avoid creating unused dummy strings.
Diffstat (limited to 'src/rpc')
-rw-r--r-- | src/rpc/mempool.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/rpc/mempool.cpp b/src/rpc/mempool.cpp index 039a4328e3..af980de6b9 100644 --- a/src/rpc/mempool.cpp +++ b/src/rpc/mempool.cpp @@ -23,6 +23,8 @@ #include <util/moneystr.h> #include <util/time.h> +#include <utility> + using kernel::DumpMempool; using node::DEFAULT_MAX_RAW_TX_FEE_RATE; @@ -449,19 +451,18 @@ static RPCHelpMan getmempoolancestors() throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool"); } - CTxMemPool::setEntries setAncestors; - std::string dummy; - mempool.CalculateMemPoolAncestors(*it, setAncestors, CTxMemPool::Limits::NoLimits(), dummy, false); + auto ancestors_result{mempool.CalculateMemPoolAncestors(*it, CTxMemPool::Limits::NoLimits(), /*fSearchForParents=*/false)}; + auto ancestors{std::move(ancestors_result).value_or(CTxMemPool::setEntries{})}; if (!fVerbose) { UniValue o(UniValue::VARR); - for (CTxMemPool::txiter ancestorIt : setAncestors) { + for (CTxMemPool::txiter ancestorIt : ancestors) { o.push_back(ancestorIt->GetTx().GetHash().ToString()); } return o; } else { UniValue o(UniValue::VOBJ); - for (CTxMemPool::txiter ancestorIt : setAncestors) { + for (CTxMemPool::txiter ancestorIt : ancestors) { const CTxMemPoolEntry &e = *ancestorIt; const uint256& _hash = e.GetTx().GetHash(); UniValue info(UniValue::VOBJ); |