Browse Source

add parameter from to listtransactions this allows querying for ranges, i.e. transactions [from, from+count)

0.8
Carlo Alberto Ferraris 14 years ago
parent
commit
5aef2c0d55
  1. 9
      rpc.cpp

9
rpc.cpp

@ -1084,8 +1084,8 @@ Value listtransactions(const Array& params, bool fHelp)
{ {
if (fHelp || params.size() > 2) if (fHelp || params.size() > 2)
throw runtime_error( throw runtime_error(
"listtransactions [account] [count=10]\n" "listtransactions [account] [count=10] [from=0]\n"
"Returns up to [count] most recent transactions for account <account>."); "Returns up to [count] most recent transactions skipping the first [from] transactions for account [account].");
string strAccount = "*"; string strAccount = "*";
if (params.size() > 0) if (params.size() > 0)
@ -1093,6 +1093,9 @@ Value listtransactions(const Array& params, bool fHelp)
int nCount = 10; int nCount = 10;
if (params.size() > 1) if (params.size() > 1)
nCount = params[1].get_int(); nCount = params[1].get_int();
int nFrom = 0;
if (params.size() > 2)
nFrom = params[2].get_int();
Array ret; Array ret;
CWalletDB walletdb; CWalletDB walletdb;
@ -1117,7 +1120,7 @@ Value listtransactions(const Array& params, bool fHelp)
} }
// Now: iterate backwards until we have nCount items to return: // Now: iterate backwards until we have nCount items to return:
for (TxItems::reverse_iterator it = txByTime.rbegin(); it != txByTime.rend(); ++it) for (TxItems::reverse_iterator it = txByTime.rbegin(), std::advance(it, nFrom); it != txByTime.rend(); ++it)
{ {
CWalletTx *const pwtx = (*it).second.first; CWalletTx *const pwtx = (*it).second.first;
if (pwtx != 0) if (pwtx != 0)

Loading…
Cancel
Save