Skip to content

Commit 083ef8f

Browse files
committed
Fix cutting of omni_listtransactions
Previously, when trying to skip transactions of omni_listtransactions, the list wasn't cut, e.g. with this command, when there were only 4 transactions in total: omni_listtransactions "*" 10 2 This commit reintroduces proper cutting of the result.
1 parent af96220 commit 083ef8f

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/omnicore/rpc.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,25 +1769,18 @@ UniValue omni_listtransactions(const UniValue& params, bool fHelp)
17691769
// reverse iterate over (now ordered) transactions and populate RPC objects for each one
17701770
UniValue response(UniValue::VARR);
17711771
for (std::map<std::string,uint256>::reverse_iterator it = walletTransactions.rbegin(); it != walletTransactions.rend(); it++) {
1772-
uint256 txHash = it->second;
1773-
UniValue txobj(UniValue::VOBJ);
1774-
int populateResult = populateRPCTransactionObject(txHash, txobj, addressParam);
1775-
if (0 == populateResult) response.push_back(txobj);
1772+
if (nFrom <= 0 && nCount > 0) {
1773+
uint256 txHash = it->second;
1774+
UniValue txobj(UniValue::VOBJ);
1775+
int populateResult = populateRPCTransactionObject(txHash, txobj, addressParam);
1776+
if (0 == populateResult) {
1777+
response.push_back(txobj);
1778+
nCount--;
1779+
}
1780+
}
1781+
nFrom--;
17761782
}
17771783

1778-
// TODO: reenable cutting!
1779-
/*
1780-
// cut on nFrom and nCount
1781-
if (nFrom > (int)response.size()) nFrom = response.size();
1782-
if ((nFrom + nCount) > (int)response.size()) nCount = response.size() - nFrom;
1783-
UniValue::iterator first = response.begin();
1784-
std::advance(first, nFrom);
1785-
UniValue::iterator last = response.begin();
1786-
std::advance(last, nFrom+nCount);
1787-
if (last != response.end()) response.erase(last, response.end());
1788-
if (first != response.begin()) response.erase(response.begin(), first);
1789-
std::reverse(response.begin(), response.end());
1790-
*/
17911784
return response;
17921785
}
17931786

0 commit comments

Comments
 (0)