From 3344e09fb555039c532db14c04a651c48dde405c Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Fri, 23 Dec 2022 11:01:57 +0530 Subject: [PATCH 01/10] Support multiple TX type filtering --- src/masternodes/rpc_accounts.cpp | 39 ++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/masternodes/rpc_accounts.cpp b/src/masternodes/rpc_accounts.cpp index 618e2c0470..d168d26889 100644 --- a/src/masternodes/rpc_accounts.cpp +++ b/src/masternodes/rpc_accounts.cpp @@ -1459,6 +1459,16 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { {"no_rewards", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED, "Filter out rewards"}, {"token", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Filter by token"}, {"txtype", RPCArg::Type::STR, RPCArg::Optional::OMITTED, "Filter by transaction type, supported letter from {CustomTxType}"}, + {"txtypes", RPCArg::Type::ARR, RPCArg::Optional::OMITTED, "Filter multiple transaction types, supported letter from {CustomTxType}", + { + { + "Transaction Type", + RPCArg::Type::STR, + RPCArg::Optional::OMITTED, + "letter from {CustomTxType}", + }, + } + }, }, }, }, @@ -1484,7 +1494,8 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { bool noRewards = false; std::string tokenFilter; - auto txType = CustomTxType::None; + std::set txTypes{}; + bool hasTxFilter = false; if (request.params.size() > 1) { UniValue optionsObj = request.params[1].get_obj(); @@ -1493,6 +1504,7 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { {"no_rewards", UniValueType(UniValue::VBOOL)}, {"token", UniValueType(UniValue::VSTR)}, {"txtype", UniValueType(UniValue::VSTR)}, + {"txtypes", UniValueType(UniValue::VOBJ)}, }, true, true); noRewards = optionsObj["no_rewards"].getBool(); @@ -1501,10 +1513,27 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { tokenFilter = optionsObj["token"].get_str(); } - if (!optionsObj["txtype"].isNull()) { + if (!optionsObj["txtypes"].isNull()) { + hasTxFilter = true; + const auto types = optionsObj["txtypes"].get_array().getValues(); + if (!types.empty()) { + for (const auto& type : types) { + auto str = type.get_str(); + if (str.size() == 1) { + txTypes.insert(CustomTxCodeToType(str[0])); + } else { + txTypes.insert(FromString(str)); + } + } + } + } + else if (!optionsObj["txtype"].isNull()) { + hasTxFilter = true; const auto str = optionsObj["txtype"].get_str(); if (str.size() == 1) { - txType = CustomTxCodeToType(str[0]); + txTypes.insert(CustomTxCodeToType(str[0])); + } else { + txTypes.insert(FromString(str)); } } } @@ -1522,7 +1551,7 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { } std::set txs; - const bool shouldSearchInWallet = (tokenFilter.empty() || tokenFilter == "DFI") && CustomTxType::None == txType; + const bool shouldSearchInWallet = (tokenFilter.empty() || tokenFilter == "DFI") && !hasTxFilter; auto hasToken = [&tokenFilter](TAmounts const & diffs) { for (auto const & diff : diffs) { @@ -1558,7 +1587,7 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { reverter = std::make_unique(view, key.owner, value.diff); } - if (CustomTxType::None != txType && value.category != uint8_t(txType)) { + if (hasTxFilter && txTypes.find(CustomTxCodeToType(value.category)) == txTypes.end()) { return true; } From 4bf6c1883d5172207c5512d38ae5b7d3f67b0f44 Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Fri, 23 Dec 2022 11:20:52 +0530 Subject: [PATCH 02/10] Support multiple account filtering --- src/masternodes/rpc_accounts.cpp | 122 +++++++++++++++++-------------- 1 file changed, 69 insertions(+), 53 deletions(-) diff --git a/src/masternodes/rpc_accounts.cpp b/src/masternodes/rpc_accounts.cpp index d168d26889..8ba9980004 100644 --- a/src/masternodes/rpc_accounts.cpp +++ b/src/masternodes/rpc_accounts.cpp @@ -1538,7 +1538,8 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { } } - CScript owner; + std::set accountSet{CScript{}}; +// CScript owner; bool isMine = false; isminetype filter = ISMINE_ALL; @@ -1546,8 +1547,15 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { isMine = true; filter = ISMINE_SPENDABLE; } else if (accounts != "all") { - owner = DecodeScript(accounts); - isMine = IsMineCached(*pwallet, owner) & ISMINE_ALL; + accountSet.clear(); + if (request.params[0].isArray()) { + for (const auto& acc: request.params[0].get_array().getValues()) + accountSet.emplace(DecodeScript(acc.get_str())); + } else { + const auto owner = DecodeScript(accounts); + accountSet.emplace(owner); + isMine = IsMineCached(*pwallet, owner) & ISMINE_ALL; + } } std::set txs; @@ -1567,69 +1575,77 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { LOCK(cs_main); CCustomCSView view(*pcustomcsview); CCoinsViewCache coins(&::ChainstateActive().CoinsTip()); - - CScript lastOwner; uint64_t count = 0; - auto lastHeight = uint32_t(::ChainActive().Height()); - const auto currentHeight = lastHeight; - auto shouldContinueToNextAccountHistory = [&](AccountHistoryKey const & key, AccountHistoryValue value) -> bool { - if (!owner.empty() && owner != key.owner) { - return false; - } + for (const auto &owner : accountSet) { + CScript lastOwner; + auto lastHeight = uint32_t(::ChainActive().Height()); + const auto currentHeight = lastHeight; - if (isMine && !(IsMineCached(*pwallet, key.owner) & filter)) { - return true; - } + auto shouldContinueToNextAccountHistory = [&](AccountHistoryKey const &key, AccountHistoryValue value) -> bool { + if (!owner.empty() && owner != key.owner) { + return false; + } - std::unique_ptr reverter; - if (!noRewards) { - reverter = std::make_unique(view, key.owner, value.diff); - } + if (isMine && !(IsMineCached(*pwallet, key.owner) & filter)) { + return true; + } - if (hasTxFilter && txTypes.find(CustomTxCodeToType(value.category)) == txTypes.end()) { - return true; - } + std::unique_ptr reverter; + if (!noRewards) { + reverter = std::make_unique(view, key.owner, value.diff); + } - if (tokenFilter.empty() || hasToken(value.diff)) { - if (shouldSearchInWallet) { - txs.insert(value.txid); + if (hasTxFilter && txTypes.find(CustomTxCodeToType(value.category)) == txTypes.end()) { + return true; } - ++count; - } - if (!noRewards) { - // starting new account - if (lastOwner != key.owner) { - view.Discard(); - lastOwner = key.owner; - lastHeight = currentHeight; + if (tokenFilter.empty() || hasToken(value.diff)) { + if (shouldSearchInWallet) { + txs.insert(value.txid); + } + ++count; } - onPoolRewards(view, key.owner, key.blockHeight, lastHeight, - [&](int32_t, DCT_ID, RewardType, CTokenAmount amount) { - if (tokenFilter.empty() || hasToken({{amount.nTokenId, amount.nValue}})) { - ++count; - } + + if (!noRewards) { + // starting new account + if (lastOwner != key.owner) { + view.Discard(); + lastOwner = key.owner; + lastHeight = currentHeight; } - ); - lastHeight = key.blockHeight; - } + onPoolRewards(view, + key.owner, + key.blockHeight, + lastHeight, + [&](int32_t, DCT_ID, RewardType, CTokenAmount amount) { + if (tokenFilter.empty() || hasToken({ + {amount.nTokenId, amount.nValue} + })) { + ++count; + } + }); + lastHeight = key.blockHeight; + } - return true; - }; + return true; + }; - paccountHistoryDB->ForEachAccountHistory(shouldContinueToNextAccountHistory, owner, currentHeight); + paccountHistoryDB->ForEachAccountHistory(shouldContinueToNextAccountHistory, owner, currentHeight); - if (shouldSearchInWallet) { - searchInWallet(pwallet, owner, filter, - [&](CBlockIndex const * index, CWalletTx const * pwtx) { - return txs.count(pwtx->GetHash()) || static_cast(index->nHeight) > currentHeight; - }, - [&count](COutputEntry const &, CBlockIndex const *, CWalletTx const *) { - ++count; - return true; - } - ); + if (shouldSearchInWallet) { + searchInWallet( + pwallet, + owner, + filter, + [&](CBlockIndex const *index, CWalletTx const *pwtx) { + return txs.count(pwtx->GetHash()) || static_cast(index->nHeight) > currentHeight; + }, + [&count](COutputEntry const &, CBlockIndex const *, CWalletTx const *) { + ++count; + return true; + }); + } } return GetRPCResultCache().Set(request, count); From 07878e8e89fa76dcfd572df94cd73bb2e074e41f Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Fri, 23 Dec 2022 11:34:12 +0530 Subject: [PATCH 03/10] Fix errors --- src/masternodes/rpc_accounts.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/masternodes/rpc_accounts.cpp b/src/masternodes/rpc_accounts.cpp index 8ba9980004..40b723a411 100644 --- a/src/masternodes/rpc_accounts.cpp +++ b/src/masternodes/rpc_accounts.cpp @@ -1504,7 +1504,7 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { {"no_rewards", UniValueType(UniValue::VBOOL)}, {"token", UniValueType(UniValue::VSTR)}, {"txtype", UniValueType(UniValue::VSTR)}, - {"txtypes", UniValueType(UniValue::VOBJ)}, + {"txtypes", UniValueType(UniValue::VARR)}, }, true, true); noRewards = optionsObj["no_rewards"].getBool(); @@ -1539,7 +1539,6 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { } std::set accountSet{CScript{}}; -// CScript owner; bool isMine = false; isminetype filter = ISMINE_ALL; From 7b1dd76c2c62ae95d3e99e971b629b02f8fe1be2 Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Sat, 14 Jan 2023 17:33:40 +0800 Subject: [PATCH 04/10] Add test for accounthistorycount --- test/functional/feature_listaccounthistory_multiaccountquery.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/functional/feature_listaccounthistory_multiaccountquery.py b/test/functional/feature_listaccounthistory_multiaccountquery.py index dd9ec493b0..7feb67a39a 100644 --- a/test/functional/feature_listaccounthistory_multiaccountquery.py +++ b/test/functional/feature_listaccounthistory_multiaccountquery.py @@ -63,9 +63,11 @@ def run_test(self): self.sync_blocks() combined = self.nodes[0].listaccounthistory([collateral_a, collateral_b]) + combined_count = self.nodes[0].accounthistorycount([collateral_a, collateral_b]) a = self.nodes[0].listaccounthistory([collateral_a]) b = self.nodes[0].listaccounthistory([collateral_b]) + assert_equal(len(combined), combined_count) assert_equal(len(combined), len(a) + len(b)) From fb703dc666f6593e7c2b868d7ae6044fb37699b0 Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Sat, 14 Jan 2023 17:42:06 +0800 Subject: [PATCH 05/10] Add more tests for accounthistorycount --- test/functional/rpc_listaccounthistory.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/functional/rpc_listaccounthistory.py b/test/functional/rpc_listaccounthistory.py index f0c66ce3ab..c9e9ca2e6d 100755 --- a/test/functional/rpc_listaccounthistory.py +++ b/test/functional/rpc_listaccounthistory.py @@ -138,10 +138,16 @@ def run_test(self): self.nodes[0].listaccounthistory(collateral_a, {"txtype": "BurnToken"}) + self.nodes[0].listaccounthistory(collateral_a, {"txtype": "MintToken"})) + assert_equal(len(self.nodes[0].listaccounthistory(collateral_a, {"txtypes": ["MintToken", "BurnToken"]})), + self.nodes[0].accounthistorycount(collateral_a, {"txtypes": ["MintToken", "BurnToken"]})) + # txtype should be ignored if txtypes is passed assert_equal(self.nodes[0].listaccounthistory(collateral_a, {"txtypes": ["MintToken", "BurnToken"]}), self.nodes[0].listaccounthistory(collateral_a, {"txtype": "BurnToken", "txtypes": ["MintToken", "BurnToken"]})) + assert_equal(self.nodes[0].accounthistorycount(collateral_a, {"txtypes": ["MintToken", "BurnToken"]}), + self.nodes[0].accounthistorycount(collateral_a, {"txtype": "BurnToken", "txtypes": ["MintToken", + "BurnToken"]})) # test pagination res0 = self.nodes[0].listaccounthistory(collateral_a, {"start": 0, "including_start": True}) From 33f35523c6605b47b095cc91b784473ba5710a9e Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Sat, 14 Jan 2023 18:14:34 +0800 Subject: [PATCH 06/10] Add early return in shouldContinueToNextAccountHistory --- src/masternodes/rpc_accounts.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/masternodes/rpc_accounts.cpp b/src/masternodes/rpc_accounts.cpp index 5cdfacc49e..86ef7c3fe5 100644 --- a/src/masternodes/rpc_accounts.cpp +++ b/src/masternodes/rpc_accounts.cpp @@ -1675,6 +1675,9 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { return false; } + if (!accountSet.empty() && accountSet.count(key.owner) == 0) + return true; + if (isMine && !(IsMineCached(*pwallet, key.owner) & filter)) { return true; } From 051fe241f4bf70309caab60a4d6bcd3d146fa01c Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Mon, 16 Jan 2023 11:26:43 +0800 Subject: [PATCH 07/10] Remove outer accountSet loop --- src/masternodes/rpc_accounts.cpp | 99 +++++++++++------------ test/functional/rpc_listaccounthistory.py | 3 + 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/masternodes/rpc_accounts.cpp b/src/masternodes/rpc_accounts.cpp index 86ef7c3fe5..60402f6960 100644 --- a/src/masternodes/rpc_accounts.cpp +++ b/src/masternodes/rpc_accounts.cpp @@ -1665,74 +1665,71 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { CCoinsViewCache coins(&::ChainstateActive().CoinsTip()); uint64_t count = 0; - for (const auto &owner : accountSet) { - CScript lastOwner; - auto lastHeight = uint32_t(::ChainActive().Height()); - const auto currentHeight = lastHeight; - - auto shouldContinueToNextAccountHistory = [&](AccountHistoryKey const &key, AccountHistoryValue value) -> bool { - if (!owner.empty() && owner != key.owner) { - return false; - } + CScript lastOwner; + auto lastHeight = uint32_t(::ChainActive().Height()); + const auto currentHeight = lastHeight; - if (!accountSet.empty() && accountSet.count(key.owner) == 0) - return true; + auto shouldContinueToNextAccountHistory = [&](AccountHistoryKey const &key, AccountHistoryValue value) -> bool { + if (!accountSet.empty() && accountSet.count(key.owner) == 0) + return true; - if (isMine && !(IsMineCached(*pwallet, key.owner) & filter)) { - return true; - } + if (isMine && !(IsMineCached(*pwallet, key.owner) & filter)) { + return true; + } - std::unique_ptr reverter; - if (!noRewards) { - reverter = std::make_unique(view, key.owner, value.diff); - } + std::unique_ptr reverter; + if (!noRewards) { + reverter = std::make_unique(view, key.owner, value.diff); + } - if (hasTxFilter && txTypes.find(CustomTxCodeToType(value.category)) == txTypes.end()) { - return true; - } + if (hasTxFilter && txTypes.find(CustomTxCodeToType(value.category)) == txTypes.end()) { + return true; + } - if (tokenFilter.empty() || hasToken(value.diff)) { - if (shouldSearchInWallet) { - txs.insert(value.txid); - } - ++count; + if (tokenFilter.empty() || hasToken(value.diff)) { + if (shouldSearchInWallet) { + txs.insert(value.txid); } + ++count; + } - if (!noRewards) { - // starting new account - if (lastOwner != key.owner) { - view.Discard(); - lastOwner = key.owner; - lastHeight = currentHeight; - } - onPoolRewards(view, - key.owner, - key.blockHeight, - lastHeight, - [&](int32_t, DCT_ID, RewardType, CTokenAmount amount) { - if (tokenFilter.empty() || hasToken({ - {amount.nTokenId, amount.nValue} - })) { - ++count; - } - }); - lastHeight = key.blockHeight; + if (!noRewards) { + // starting new account + if (lastOwner != key.owner) { + view.Discard(); + lastOwner = key.owner; + lastHeight = currentHeight; } + onPoolRewards(view, + key.owner, + key.blockHeight, + lastHeight, + [&](int32_t, DCT_ID, RewardType, CTokenAmount amount) { + if (tokenFilter.empty() || hasToken({ + {amount.nTokenId, amount.nValue} + })) { + ++count; + } + }); + lastHeight = key.blockHeight; + } - return true; - }; + return true; + }; - paccountHistoryDB->ForEachAccountHistory(shouldContinueToNextAccountHistory, owner, currentHeight); + paccountHistoryDB->ForEachAccountHistory( + shouldContinueToNextAccountHistory, *accountSet.begin(), currentHeight); - if (shouldSearchInWallet) { + if (shouldSearchInWallet) { + for (const auto &owner : accountSet) { searchInWallet( pwallet, owner, filter, - [&](CBlockIndex const *index, CWalletTx const *pwtx) { + [&](const CBlockIndex *index, const CWalletTx *pwtx) { return txs.count(pwtx->GetHash()) || static_cast(index->nHeight) > currentHeight; }, - [&count](COutputEntry const &, CBlockIndex const *, CWalletTx const *) { + [&count](const COutputEntry &, const CBlockIndex *, const CWalletTx *) { ++count; return true; }); diff --git a/test/functional/rpc_listaccounthistory.py b/test/functional/rpc_listaccounthistory.py index c9e9ca2e6d..8a92e6aa35 100755 --- a/test/functional/rpc_listaccounthistory.py +++ b/test/functional/rpc_listaccounthistory.py @@ -165,6 +165,9 @@ def run_test(self): assert_equal(len(res0), len(res2) + 2) assert_equal(len(res0), len(res3) + 3) + # accounthistorycount should return total count + assert_equal(self.nodes[0].accounthistorycount(), 115) + # REVERTING: # ======================== self.start_node(2) From 00597e50cb165ef17e031868b332e5ca2101a0e9 Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Mon, 16 Jan 2023 16:43:10 +0800 Subject: [PATCH 08/10] Revert "Remove outer accountSet loop" This reverts commit 051fe241f4bf70309caab60a4d6bcd3d146fa01c. --- src/masternodes/rpc_accounts.cpp | 99 ++++++++++++----------- test/functional/rpc_listaccounthistory.py | 3 - 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/masternodes/rpc_accounts.cpp b/src/masternodes/rpc_accounts.cpp index 60402f6960..86ef7c3fe5 100644 --- a/src/masternodes/rpc_accounts.cpp +++ b/src/masternodes/rpc_accounts.cpp @@ -1665,71 +1665,74 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { CCoinsViewCache coins(&::ChainstateActive().CoinsTip()); uint64_t count = 0; - CScript lastOwner; - auto lastHeight = uint32_t(::ChainActive().Height()); - const auto currentHeight = lastHeight; + for (const auto &owner : accountSet) { + CScript lastOwner; + auto lastHeight = uint32_t(::ChainActive().Height()); + const auto currentHeight = lastHeight; - auto shouldContinueToNextAccountHistory = [&](AccountHistoryKey const &key, AccountHistoryValue value) -> bool { - if (!accountSet.empty() && accountSet.count(key.owner) == 0) - return true; + auto shouldContinueToNextAccountHistory = [&](AccountHistoryKey const &key, AccountHistoryValue value) -> bool { + if (!owner.empty() && owner != key.owner) { + return false; + } - if (isMine && !(IsMineCached(*pwallet, key.owner) & filter)) { - return true; - } + if (!accountSet.empty() && accountSet.count(key.owner) == 0) + return true; - std::unique_ptr reverter; - if (!noRewards) { - reverter = std::make_unique(view, key.owner, value.diff); - } + if (isMine && !(IsMineCached(*pwallet, key.owner) & filter)) { + return true; + } - if (hasTxFilter && txTypes.find(CustomTxCodeToType(value.category)) == txTypes.end()) { - return true; - } + std::unique_ptr reverter; + if (!noRewards) { + reverter = std::make_unique(view, key.owner, value.diff); + } - if (tokenFilter.empty() || hasToken(value.diff)) { - if (shouldSearchInWallet) { - txs.insert(value.txid); + if (hasTxFilter && txTypes.find(CustomTxCodeToType(value.category)) == txTypes.end()) { + return true; } - ++count; - } - if (!noRewards) { - // starting new account - if (lastOwner != key.owner) { - view.Discard(); - lastOwner = key.owner; - lastHeight = currentHeight; + if (tokenFilter.empty() || hasToken(value.diff)) { + if (shouldSearchInWallet) { + txs.insert(value.txid); + } + ++count; } - onPoolRewards(view, - key.owner, - key.blockHeight, - lastHeight, - [&](int32_t, DCT_ID, RewardType, CTokenAmount amount) { - if (tokenFilter.empty() || hasToken({ - {amount.nTokenId, amount.nValue} - })) { - ++count; - } - }); - lastHeight = key.blockHeight; - } - return true; - }; + if (!noRewards) { + // starting new account + if (lastOwner != key.owner) { + view.Discard(); + lastOwner = key.owner; + lastHeight = currentHeight; + } + onPoolRewards(view, + key.owner, + key.blockHeight, + lastHeight, + [&](int32_t, DCT_ID, RewardType, CTokenAmount amount) { + if (tokenFilter.empty() || hasToken({ + {amount.nTokenId, amount.nValue} + })) { + ++count; + } + }); + lastHeight = key.blockHeight; + } - paccountHistoryDB->ForEachAccountHistory( - shouldContinueToNextAccountHistory, *accountSet.begin(), currentHeight); + return true; + }; + + paccountHistoryDB->ForEachAccountHistory(shouldContinueToNextAccountHistory, owner, currentHeight); - if (shouldSearchInWallet) { - for (const auto &owner : accountSet) { + if (shouldSearchInWallet) { searchInWallet( pwallet, owner, filter, - [&](const CBlockIndex *index, const CWalletTx *pwtx) { + [&](CBlockIndex const *index, CWalletTx const *pwtx) { return txs.count(pwtx->GetHash()) || static_cast(index->nHeight) > currentHeight; }, - [&count](const COutputEntry &, const CBlockIndex *, const CWalletTx *) { + [&count](COutputEntry const &, CBlockIndex const *, CWalletTx const *) { ++count; return true; }); diff --git a/test/functional/rpc_listaccounthistory.py b/test/functional/rpc_listaccounthistory.py index 8a92e6aa35..c9e9ca2e6d 100755 --- a/test/functional/rpc_listaccounthistory.py +++ b/test/functional/rpc_listaccounthistory.py @@ -165,9 +165,6 @@ def run_test(self): assert_equal(len(res0), len(res2) + 2) assert_equal(len(res0), len(res3) + 3) - # accounthistorycount should return total count - assert_equal(self.nodes[0].accounthistorycount(), 115) - # REVERTING: # ======================== self.start_node(2) From bbda15f2f7544e02d83f382a8b37b239a80ad8c1 Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Mon, 16 Jan 2023 16:43:15 +0800 Subject: [PATCH 09/10] Revert "Add early return in shouldContinueToNextAccountHistory" This reverts commit 33f35523c6605b47b095cc91b784473ba5710a9e. --- src/masternodes/rpc_accounts.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/masternodes/rpc_accounts.cpp b/src/masternodes/rpc_accounts.cpp index 86ef7c3fe5..5cdfacc49e 100644 --- a/src/masternodes/rpc_accounts.cpp +++ b/src/masternodes/rpc_accounts.cpp @@ -1675,9 +1675,6 @@ UniValue accounthistorycount(const JSONRPCRequest& request) { return false; } - if (!accountSet.empty() && accountSet.count(key.owner) == 0) - return true; - if (isMine && !(IsMineCached(*pwallet, key.owner) & filter)) { return true; } From 20e6f3b2279e6b2797d18b1e6ab8c341ef45f990 Mon Sep 17 00:00:00 2001 From: Shoham Chakraborty Date: Mon, 16 Jan 2023 16:45:06 +0800 Subject: [PATCH 10/10] Add total count test --- test/functional/rpc_listaccounthistory.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/functional/rpc_listaccounthistory.py b/test/functional/rpc_listaccounthistory.py index c9e9ca2e6d..60af58c64a 100755 --- a/test/functional/rpc_listaccounthistory.py +++ b/test/functional/rpc_listaccounthistory.py @@ -165,6 +165,9 @@ def run_test(self): assert_equal(len(res0), len(res2) + 2) assert_equal(len(res0), len(res3) + 3) + # accounthistorycount should return total count + assert_equal(self.nodes[0].accounthistorycount(), 112) + # REVERTING: # ======================== self.start_node(2)