From ffc04e7399d124cccec6672e3d9e8ad202301cee Mon Sep 17 00:00:00 2001 From: Jianping Wu Date: Tue, 12 Feb 2019 15:51:23 -0800 Subject: [PATCH] 1. Handled "too-long-mempool-chain" by deleting the offending Tx so that it is not in mempool and will not affect the subsequent operations. 2. Fixed typos in keva_filter output and help message. --- src/rpc/rpckeva_nonwallet.cpp | 36 +++++++++++++++++------------------ src/wallet/wallet.cpp | 8 +++++++- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/rpc/rpckeva_nonwallet.cpp b/src/rpc/rpckeva_nonwallet.cpp index 872df99cf..1d56498d0 100644 --- a/src/rpc/rpckeva_nonwallet.cpp +++ b/src/rpc/rpckeva_nonwallet.cpp @@ -91,37 +91,37 @@ std::string getKevaInfoHelp (const std::string& indent, const std::string& trail std::ostringstream res; res << indent << "{" << std::endl; - res << indent << " \"name\": xxxxx, " - << "(string) the requested name" << std::endl; + res << indent << " \"key\": xxxxx, " + << "(string) the requested key" << std::endl; res << indent << " \"value\": xxxxx, " - << "(string) the name's current value" << std::endl; + << "(string) the key's current value" << std::endl; res << indent << " \"txid\": xxxxx, " - << "(string) the name's last update tx" << std::endl; + << "(string) the key's last update tx" << std::endl; res << indent << " \"address\": xxxxx, " - << "(string) the address holding the name" << std::endl; + << "(string) the address holding the key" << std::endl; res << indent << " \"height\": xxxxx, " - << "(numeric) the name's last update height" << std::endl; + << "(numeric) the key's last update height" << std::endl; res << indent << "}" << trailing << std::endl; return res.str (); } /** - * Utility routine to construct a "name info" object to return. This is used + * Utility routine to construct a "keva info" object to return. This is used * for keva_filter. - * @param name The name. - * @param value The name's value. + * @param key The key. + * @param value The key's value. * @param outp The last update's outpoint. - * @param addr The name's address script. - * @param height The name's last update height. + * @param addr The key's address script. + * @param height The key's last update height. * @return A JSON object to return. */ UniValue -getKevaInfo (const valtype& name, const valtype& value, const COutPoint& outp, +getKevaInfo(const valtype& key, const valtype& value, const COutPoint& outp, const CScript& addr, int height) { UniValue obj(UniValue::VOBJ); - obj.pushKV("name", ValtypeToString(name)); + obj.pushKV("key", ValtypeToString(key)); obj.pushKV("value", ValtypeToString(value)); obj.pushKV("txid", outp.hash.GetHex()); obj.pushKV("vout", static_cast(outp.n)); @@ -141,15 +141,15 @@ getKevaInfo (const valtype& name, const valtype& value, const COutPoint& outp, } /** - * Return name info object for a CNameData object. - * @param name The name. - * @param data The name's data. + * Return keva info object for a CKevaData object. + * @param key The key. + * @param data The key's data. * @return A JSON object to return. */ UniValue -getKevaInfo (const valtype& name, const CKevaData& data) +getKevaInfo(const valtype& key, const CKevaData& data) { - return getKevaInfo(name, data.getValue(), data.getUpdateOutpoint(), + return getKevaInfo(key, data.getValue(), data.getUpdateOutpoint(), data.getAddress(), data.getHeight()); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f9aeb2c89..99f28f1f7 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3167,8 +3167,14 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CCon { // Broadcast if (!wtx.AcceptToMemoryPool(maxTxFee, state)) { - LogPrintf("CommitTransaction(): Transaction cannot be broadcast immediately, %s\n", state.GetRejectReason()); + auto rejectReason = state.GetRejectReason(); + LogPrintf("CommitTransaction(): Transaction cannot be broadcast immediately, %s\n", rejectReason); // TODO: if we expect the failure to be long term or permanent, instead delete wtx from the wallet and return failure. + if (rejectReason == "too-long-mempool-chain") { + LogPrintf("Abandon the too-long-mempool-chain Tx: %s \n", wtx.GetHash().ToString().c_str()); + AbandonTransaction(wtx.GetHash()); + return false; + } } else { wtx.RelayWalletTransaction(connman); }