diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -133,7 +133,7 @@ {"keypoolrefill", 0, "newsize"}, {"getrawmempool", 0, "verbose"}, {"estimatefee", 0, "nblocks"}, - {"prioritisetransaction", 1, "priority_delta"}, + {"prioritisetransaction", 1, "dummy"}, {"prioritisetransaction", 2, "fee_delta"}, {"setban", 2, "bantime"}, {"setban", 3, "absolute"}, diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -268,17 +268,12 @@ const JSONRPCRequest &request) { if (request.fHelp || request.params.size() != 3) { throw std::runtime_error( - "prioritisetransaction \n" + "prioritisetransaction \n" "Accepts the transaction into mined blocks at a higher (or lower) " "priority\n" "\nArguments:\n" "1. \"txid\" (string, required) The transaction id.\n" - "2. priority_delta (numeric, required) The priority to add or " - "subtract.\n" - " The transaction selection algorithm considers " - "the tx as it would have a higher priority.\n" - " (priority of a transaction is calculated: " - "coinage * value_in_satoshis / txsize) \n" + "2. dummy (required) unused.\n" "3. fee_delta (numeric, required) The fee value (in satoshis) " "to add (or subtract, if negative).\n" " The fee is not actually paid, only the " @@ -297,8 +292,7 @@ TxId txid(ParseHashStr(request.params[0].get_str(), "txid")); Amount nAmount = request.params[2].get_int64() * SATOSHI; - g_mempool.PrioritiseTransaction(txid, request.params[1].get_real(), - nAmount); + g_mempool.PrioritiseTransaction(txid, nAmount); return true; } @@ -815,7 +809,7 @@ // ---------- ------------------------ ---------------------- ---------- {"mining", "getnetworkhashps", getnetworkhashps, {"nblocks", "height"}}, {"mining", "getmininginfo", getmininginfo, {}}, - {"mining", "prioritisetransaction", prioritisetransaction, {"txid", "priority_delta", "fee_delta"}}, + {"mining", "prioritisetransaction", prioritisetransaction, {"txid", "dummy", "fee_delta"}}, {"mining", "getblocktemplate", getblocktemplate, {"template_request"}}, {"mining", "submitblock", submitblock, {"hexdata", "dummy"}}, {"mining", "submitheader", submitheader, {"hexdata"}}, diff --git a/src/txmempool.h b/src/txmempool.h --- a/src/txmempool.h +++ b/src/txmempool.h @@ -379,8 +379,6 @@ } }; -typedef std::pair TXModifier; - /** * CTxMemPool stores valid-according-to-the-current-best-chain transactions that * may be included in the next block. @@ -578,7 +576,7 @@ public: indirectmap mapNextTx GUARDED_BY(cs); - std::map mapDeltas; + std::map mapDeltas; /** * Create a new CTxMemPool. @@ -637,10 +635,8 @@ bool HasNoInputsOf(const CTransaction &tx) const; /** Affect CreateNewBlock prioritisation of transactions */ - void PrioritiseTransaction(const TxId &txid, double dPriorityDelta, - const Amount nFeeDelta); - void ApplyDeltas(const TxId &txid, double &dPriorityDelta, - Amount &nFeeDelta) const; + void PrioritiseTransaction(const TxId &txid, const Amount nFeeDelta); + void ApplyDelta(const TxId &txid, Amount &nFeeDelta) const; void ClearPrioritisation(const TxId &txid); /** Get the transaction in the pool that spends the same prevout */ diff --git a/src/txmempool.cpp b/src/txmempool.cpp --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -400,9 +400,8 @@ // Update transaction for any feeDelta created by PrioritiseTransaction // TODO: refactor so that the fee delta is calculated before inserting into // mapTx. - double priorityDelta = 0; Amount feeDelta = Amount::zero(); - ApplyDeltas(entry.GetTx().GetId(), priorityDelta, feeDelta); + ApplyDelta(entry.GetTx().GetId(), feeDelta); if (feeDelta != Amount::zero()) { mapTx.modify(newit, update_fee_delta(feeDelta)); } @@ -911,16 +910,15 @@ return std::max(::minRelayTxFee, GetMinFee(maxMempoolSize)); } -void CTxMemPool::PrioritiseTransaction(const TxId &txid, double dPriorityDelta, +void CTxMemPool::PrioritiseTransaction(const TxId &txid, const Amount nFeeDelta) { { LOCK(cs); - TXModifier &deltas = mapDeltas[txid]; - deltas.first += dPriorityDelta; - deltas.second += nFeeDelta; + Amount &delta = mapDeltas[txid]; + delta += nFeeDelta; txiter it = mapTx.find(txid); if (it != mapTx.end()) { - mapTx.modify(it, update_fee_delta(deltas.second)); + mapTx.modify(it, update_fee_delta(delta)); // Now update all ancestors' modified fees with descendants setEntries setAncestors; uint64_t nNoLimit = std::numeric_limits::max(); @@ -943,21 +941,18 @@ ++nTransactionsUpdated; } } - LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", - txid.ToString(), dPriorityDelta, FormatMoney(nFeeDelta)); + LogPrintf("PrioritiseTransaction: %s fee += %s\n", txid.ToString(), + FormatMoney(nFeeDelta)); } -void CTxMemPool::ApplyDeltas(const TxId &txid, double &dPriorityDelta, - Amount &nFeeDelta) const { +void CTxMemPool::ApplyDelta(const TxId &txid, Amount &nFeeDelta) const { LOCK(cs); - std::map::const_iterator pos = mapDeltas.find(txid); + std::map::const_iterator pos = mapDeltas.find(txid); if (pos == mapDeltas.end()) { return; } - const TXModifier &deltas = pos->second; - dPriorityDelta += deltas.first; - nFeeDelta += deltas.second; + nFeeDelta += pos->second; } void CTxMemPool::ClearPrioritisation(const TxId &txid) { diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -668,8 +668,7 @@ // nModifiedFees includes any fee deltas from PrioritiseTransaction Amount nModifiedFees = nFees; - double nPriorityDummy = 0; - pool.ApplyDeltas(txid, nPriorityDummy, nModifiedFees); + pool.ApplyDelta(txid, nModifiedFees); // Keep track of transactions that spend a coinbase, which we re-scan // during reorgs to ensure COINBASE_MATURITY is still met. @@ -5500,7 +5499,6 @@ uint64_t num; file >> num; - double prioritydummy = 0; while (num--) { CTransactionRef tx; int64_t nTime; @@ -5511,8 +5509,7 @@ Amount amountdelta = nFeeDelta * SATOSHI; if (amountdelta != Amount::zero()) { - pool.PrioritiseTransaction(tx->GetId(), prioritydummy, - amountdelta); + pool.PrioritiseTransaction(tx->GetId(), amountdelta); } CValidationState state; if (nTime + nExpiryTimeout > nNow) { @@ -5546,7 +5543,7 @@ file >> mapDeltas; for (const auto &i : mapDeltas) { - pool.PrioritiseTransaction(i.first, prioritydummy, i.second); + pool.PrioritiseTransaction(i.first, i.second); } } catch (const std::exception &e) { LogPrintf("Failed to deserialize mempool data on disk: %s. Continuing " @@ -5573,7 +5570,7 @@ { LOCK(pool.cs); for (const auto &i : pool.mapDeltas) { - mapDeltas[i.first] = i.second.second; + mapDeltas[i.first] = i.second; } vinfo = pool.infoAll();