Browse Source

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.
cn
Jianping Wu 5 years ago
parent
commit
ffc04e7399
  1. 36
      src/rpc/rpckeva_nonwallet.cpp
  2. 8
      src/wallet/wallet.cpp

36
src/rpc/rpckeva_nonwallet.cpp

@ -91,37 +91,37 @@ std::string getKevaInfoHelp (const std::string& indent, const std::string& trail
std::ostringstream res; std::ostringstream res;
res << indent << "{" << std::endl; res << indent << "{" << std::endl;
res << indent << " \"name\": xxxxx, " res << indent << " \"key\": xxxxx, "
<< "(string) the requested name" << std::endl; << "(string) the requested key" << std::endl;
res << indent << " \"value\": xxxxx, " res << indent << " \"value\": xxxxx, "
<< "(string) the name's current value" << std::endl; << "(string) the key's current value" << std::endl;
res << indent << " \"txid\": xxxxx, " 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, " res << indent << " \"address\": xxxxx, "
<< "(string) the address holding the name" << std::endl; << "(string) the address holding the key" << std::endl;
res << indent << " \"height\": xxxxx, " 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; res << indent << "}" << trailing << std::endl;
return res.str (); 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. * for keva_filter.
* @param name The name. * @param key The key.
* @param value The name's value. * @param value The key's value.
* @param outp The last update's outpoint. * @param outp The last update's outpoint.
* @param addr The name's address script. * @param addr The key's address script.
* @param height The name's last update height. * @param height The key's last update height.
* @return A JSON object to return. * @return A JSON object to return.
*/ */
UniValue 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) const CScript& addr, int height)
{ {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.pushKV("name", ValtypeToString(name)); obj.pushKV("key", ValtypeToString(key));
obj.pushKV("value", ValtypeToString(value)); obj.pushKV("value", ValtypeToString(value));
obj.pushKV("txid", outp.hash.GetHex()); obj.pushKV("txid", outp.hash.GetHex());
obj.pushKV("vout", static_cast<int>(outp.n)); obj.pushKV("vout", static_cast<int>(outp.n));
@ -141,15 +141,15 @@ getKevaInfo (const valtype& name, const valtype& value, const COutPoint& outp,
} }
/** /**
* Return name info object for a CNameData object. * Return keva info object for a CKevaData object.
* @param name The name. * @param key The key.
* @param data The name's data. * @param data The key's data.
* @return A JSON object to return. * @return A JSON object to return.
*/ */
UniValue 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()); data.getAddress(), data.getHeight());
} }

8
src/wallet/wallet.cpp

@ -3167,8 +3167,14 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CCon
{ {
// Broadcast // Broadcast
if (!wtx.AcceptToMemoryPool(maxTxFee, state)) { 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. // 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 { } else {
wtx.RelayWalletTransaction(connman); wtx.RelayWalletTransaction(connman);
} }

Loading…
Cancel
Save