Merge branch 'fix/expired-log-and-sweep-error' into dev
This commit is contained in:
@@ -461,6 +461,9 @@ bool AsyncRPCOperation_autoshieldcoinbase::main_impl() {
|
||||
}
|
||||
|
||||
LogPrintf("%s: autoshield tx FAILED in CommitTransaction, txid=%s\n", opid, tx.GetHash().ToString());
|
||||
set_error_code(RPC_WALLET_ERROR);
|
||||
set_error_message(strprintf("Autoshield transaction %s was not accepted into the mempool (see debug.log for the "
|
||||
"reason). The next round tries again.", tx.GetHash().ToString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -411,6 +411,12 @@ bool AsyncRPCOperation_sweep::main_impl() {
|
||||
numTxCreated++;
|
||||
} else {
|
||||
LogPrintf("%s: Sweep transaction FAILED in CommitTransaction, txid=%s\n",opid , tx.GetHash().ToString());
|
||||
// Say why the round failed: this used to finish as "failed" with an empty error. The mempool's
|
||||
// reason is in debug.log just above (most often a note already spent by another transaction).
|
||||
set_error_code(RPC_WALLET_ERROR);
|
||||
set_error_message(strprintf("Sweep transaction %s was not accepted into the mempool (see debug.log for "
|
||||
"the reason; usually one of its notes was spent by another transaction "
|
||||
"meanwhile). The next round sweeps what is left.", tx.GetHash().ToString()));
|
||||
setSweepResult(numTxCreated, amountSwept, sweepTxIds);
|
||||
status = false;
|
||||
break;
|
||||
|
||||
+15
-3
@@ -4351,7 +4351,9 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime)
|
||||
{
|
||||
std::vector<uint256> result;
|
||||
|
||||
LOCK(cs_wallet);
|
||||
// Both callers (the periodic Broadcast signal from SendMessages, and resendwallettransactions) hold
|
||||
// cs_main already; GetDepthInMainChain below needs it.
|
||||
LOCK2(cs_main, cs_wallet);
|
||||
// Sort them in chronological order
|
||||
multimap<unsigned int, CWalletTx*> mapSorted;
|
||||
uint32_t now = (uint32_t)time(NULL);
|
||||
@@ -4359,7 +4361,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime)
|
||||
|
||||
// vector of wallet transactions to delete
|
||||
std::vector<uint256> vwtxh;
|
||||
uint32_t erased = 0, skipped = 0;
|
||||
uint32_t erased = 0, skipped = 0, expired = 0;
|
||||
|
||||
BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet)
|
||||
{
|
||||
@@ -4368,10 +4370,18 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime)
|
||||
if (wtx.nTimeReceived > nTime)
|
||||
continue;
|
||||
|
||||
// A mined transaction has nothing to rebroadcast. It used to reach the expiry test below, and every
|
||||
// confirmed tx is past its expiry height a few hundred blocks after it was mined, so each pass logged
|
||||
// one "ignoring expired tx" line per wallet tx ever made: 1.1M lines (354 MB of debug.log) in a day on
|
||||
// an exchange-style wallet of ~15k txs.
|
||||
if (wtx.GetDepthInMainChain() > 0)
|
||||
continue;
|
||||
|
||||
// Do not relay expired transactions, to avoid other nodes banning us
|
||||
// Current code will not ban nodes relaying expired txs but older nodes will
|
||||
if (wtx.nExpiryHeight > 0 && wtx.nExpiryHeight < chainActive.LastTip()->GetHeight()) {
|
||||
LogPrintf("%s: ignoring expired tx %s with expiry %d at height %d\n", __func__, wtx.GetHash().ToString().c_str(), wtx.nExpiryHeight, chainActive.LastTip()->GetHeight() );
|
||||
LogPrint("wallet", "%s: ignoring expired tx %s with expiry %d at height %d\n", __func__, wtx.GetHash().ToString().c_str(), wtx.nExpiryHeight, chainActive.LastTip()->GetHeight() );
|
||||
expired++;
|
||||
// TODO: expired detection doesn't seem to work right
|
||||
// append to list of txs to delete
|
||||
// vwtxh.push_back(wtx.GetHash());
|
||||
@@ -4417,6 +4427,8 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime)
|
||||
if(erased > 0 || skipped > 0) {
|
||||
LogPrintf("%s: Prevented relaying %d and erased %d transactions which are too old\n", __func__, skipped, erased);
|
||||
}
|
||||
if (expired > 0)
|
||||
LogPrintf("%s: not relaying %u expired unconfirmed transaction(s) (-debug=wallet lists them)\n", __func__, expired);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user