Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listtransaciton performance fix #1018

Merged
merged 3 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-elysiumshowblockconsensushash=<number>", "Calculate and log the consensus hash for the specified block");
#endif

strUsage += HelpMessageOpt("-skipmnpayoutcheck", _("Do not check for masternode payout when handling listtransactions, listsinceblock and gettransaction calls (improves performance)"));

return strUsage;
}

Expand Down Expand Up @@ -1403,6 +1405,7 @@ bool AppInitParameterInteraction()
}
}
}
fSkipMnpayoutCheck = GetBoolArg("-skipmnpayoutcheck", false);
return true;
}

Expand Down
1 change: 0 additions & 1 deletion src/rpc/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "listtransactions", 1, "count" },
{ "listtransactions", 2, "skip" },
{ "listtransactions", 3, "include_watchonly" },
{ "listtransactions", 4, "skip_mnout_check" },
{ "listaccounts", 0, "minconf" },
{ "listaccounts", 1, "include_watchonly" },
{ "walletpassphrase", 1, "timeout" },
Expand Down
1 change: 1 addition & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ bool fLogTimestamps = DEFAULT_LOGTIMESTAMPS;
bool fLogTimeMicros = DEFAULT_LOGTIMEMICROS;
bool fLogIPs = DEFAULT_LOGIPS;

bool fSkipMnpayoutCheck = false;

std::atomic<bool> fReopenDebugLog(false);
CTranslationInterface translationInterface;
Expand Down
1 change: 1 addition & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ extern std::atomic<bool> fReopenElysiumLog;
extern const char * const BITCOIN_CONF_FILENAME;
extern const char * const BITCOIN_PID_FILENAME;

extern bool fSkipMnpayoutCheck;

/**
* Translation function: Call Translate signal on UI interface, which returns a boost::optional result.
Expand Down
17 changes: 6 additions & 11 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,7 @@ static void MaybePushAddress(UniValue & entry, const CTxDestination &dest, CBitc
entry.push_back(Pair("address", addr.ToString()));
}

void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter, bool omitNmPayments)
void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter)
{
CAmount nFee;
string strSentAccount;
Expand Down Expand Up @@ -1553,8 +1553,7 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const strin
int txHeight = chainActive.Height() - wtx.GetDepthInMainChain();

bool its_znode_payment = false;

if (!omitNmPayments) {
if (!fSkipMnpayoutCheck) {
std::vector<CTxOut> voutMasternodePaymentsRet;
mnpayments.GetBlockTxOuts(txHeight, CAmount(), voutMasternodePaymentsRet);
//compare address of payee to addr.
Expand Down Expand Up @@ -1618,7 +1617,7 @@ UniValue listtransactions(const JSONRPCRequest& request)
return NullUniValue;
}

if (request.fHelp || request.params.size() > 5)
if (request.fHelp || request.params.size() > 4)
throw runtime_error(
"listtransactions ( \"account\" count skip include_watchonly)\n"
"\nReturns up to 'count' most recent transactions skipping the first 'from' transactions for account 'account'.\n"
Expand All @@ -1627,7 +1626,6 @@ UniValue listtransactions(const JSONRPCRequest& request)
"2. count (numeric, optional, default=10) The number of transactions to return\n"
"3. skip (numeric, optional, default=0) The number of transactions to skip\n"
"4. include_watchonly (bool, optional, default=false) Include transactions to watch-only addresses (see 'importaddress')\n"
"5. skip_mnout_check (bool, optional, default=false) Skip checking for masternode payment txout (improves performance)\n"
"\nResult:\n"
"[\n"
" {\n"
Expand Down Expand Up @@ -1694,9 +1692,6 @@ UniValue listtransactions(const JSONRPCRequest& request)
if(request.params.size() > 3)
if(request.params[3].get_bool())
filter = filter | ISMINE_WATCH_ONLY;
bool omitNmPayments = false;
if(request.params.size() > 4)
omitNmPayments = request.params[4].get_bool();

if (nCount < 0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative count");
Expand All @@ -1712,7 +1707,7 @@ UniValue listtransactions(const JSONRPCRequest& request)
{
CWalletTx *const pwtx = (*it).second.first;
if (pwtx != 0)
ListTransactions(pwallet, *pwtx, strAccount, 0, true, ret, filter, omitNmPayments);
ListTransactions(pwallet, *pwtx, strAccount, 0, true, ret, filter);
CAccountingEntry *const pacentry = (*it).second.second;
if (pacentry != 0)
AcentryToJSON(*pacentry, strAccount, ret);
Expand Down Expand Up @@ -1921,7 +1916,7 @@ UniValue listsinceblock(const JSONRPCRequest& request)
CWalletTx tx = pairWtx.second;

if (depth == -1 || tx.GetDepthInMainChain() < depth)
ListTransactions(pwallet, tx, "*", 0, true, transactions, filter, false);
ListTransactions(pwallet, tx, "*", 0, true, transactions, filter);
}

CBlockIndex *pblockLast = chainActive[chainActive.Height() + 1 - target_confirms];
Expand Down Expand Up @@ -2017,7 +2012,7 @@ UniValue gettransaction(const JSONRPCRequest& request)
WalletTxToJSON(wtx, entry);

UniValue details(UniValue::VARR);
ListTransactions(pwallet, wtx, "*", 0, false, details, filter, false);
ListTransactions(pwallet, wtx, "*", 0, false, details, filter);
entry.push_back(Pair("details", details));

string strHex = EncodeHexTx(static_cast<CTransaction>(wtx), RPCSerializationFlags());
Expand Down