Skip to content

Commit b3e42b6

Browse files
committed
Merge #8059: Remove unneeded feerate param from RelayTransaction/AcceptToMemoryPool.
d87b198 Remove unneeded feerate param from RelayTransaction/AcceptToMemoryPool. (Gregory Maxwell)
2 parents 169d379 + d87b198 commit b3e42b6

File tree

7 files changed

+17
-25
lines changed

7 files changed

+17
-25
lines changed

src/main.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ std::string FormatStateMessage(const CValidationState &state)
10051005
}
10061006

10071007
bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const CTransaction& tx, bool fLimitFree,
1008-
bool* pfMissingInputs, CFeeRate* txFeeRate, bool fOverrideMempoolLimit, const CAmount& nAbsurdFee,
1008+
bool* pfMissingInputs, bool fOverrideMempoolLimit, const CAmount& nAbsurdFee,
10091009
std::vector<uint256>& vHashTxnToUncache)
10101010
{
10111011
const uint256 hash = tx.GetHash();
@@ -1170,9 +1170,6 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
11701170

11711171
CTxMemPoolEntry entry(tx, nFees, GetTime(), dPriority, chainActive.Height(), pool.HasNoInputsOf(tx), inChainInputValue, fSpendsCoinbase, nSigOps, lp);
11721172
unsigned int nSize = entry.GetTxSize();
1173-
if (txFeeRate) {
1174-
*txFeeRate = CFeeRate(nFees, nSize);
1175-
}
11761173

11771174
// Check that the transaction doesn't have an excessive number of
11781175
// sigops, making it impossible to mine. Since the coinbase transaction
@@ -1421,10 +1418,10 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
14211418
}
14221419

14231420
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
1424-
bool* pfMissingInputs, CFeeRate* txFeeRate, bool fOverrideMempoolLimit, const CAmount nAbsurdFee)
1421+
bool* pfMissingInputs, bool fOverrideMempoolLimit, const CAmount nAbsurdFee)
14251422
{
14261423
std::vector<uint256> vHashTxToUncache;
1427-
bool res = AcceptToMemoryPoolWorker(pool, state, tx, fLimitFree, pfMissingInputs, txFeeRate, fOverrideMempoolLimit, nAbsurdFee, vHashTxToUncache);
1424+
bool res = AcceptToMemoryPoolWorker(pool, state, tx, fLimitFree, pfMissingInputs, fOverrideMempoolLimit, nAbsurdFee, vHashTxToUncache);
14281425
if (!res) {
14291426
BOOST_FOREACH(const uint256& hashTx, vHashTxToUncache)
14301427
pcoinsTip->Uncache(hashTx);
@@ -2651,7 +2648,7 @@ bool static DisconnectTip(CValidationState& state, const CChainParams& chainpara
26512648
// ignore validation errors in resurrected transactions
26522649
list<CTransaction> removed;
26532650
CValidationState stateDummy;
2654-
if (tx.IsCoinBase() || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL, NULL, true)) {
2651+
if (tx.IsCoinBase() || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL, true)) {
26552652
mempool.removeRecursive(tx, removed);
26562653
} else if (mempool.exists(tx.GetHash())) {
26572654
vHashUpdate.push_back(tx.GetHash());
@@ -4956,10 +4953,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
49564953
pfrom->setAskFor.erase(inv.hash);
49574954
mapAlreadyAskedFor.erase(inv.hash);
49584955

4959-
CFeeRate txFeeRate = CFeeRate(0);
4960-
if (!AlreadyHave(inv) && AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs, &txFeeRate)) {
4956+
if (!AlreadyHave(inv) && AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs)) {
49614957
mempool.check(pcoinsTip);
4962-
RelayTransaction(tx, txFeeRate);
4958+
RelayTransaction(tx);
49634959
vWorkQueue.push_back(inv.hash);
49644960

49654961
LogPrint("mempool", "AcceptToMemoryPool: peer=%d: accepted %s (poolsz %u txn, %u kB)\n",
@@ -4990,10 +4986,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
49904986

49914987
if (setMisbehaving.count(fromPeer))
49924988
continue;
4993-
CFeeRate orphanFeeRate = CFeeRate(0);
4994-
if (AcceptToMemoryPool(mempool, stateDummy, orphanTx, true, &fMissingInputs2, &orphanFeeRate)) {
4989+
if (AcceptToMemoryPool(mempool, stateDummy, orphanTx, true, &fMissingInputs2)) {
49954990
LogPrint("mempool", " accepted orphan tx %s\n", orphanHash.ToString());
4996-
RelayTransaction(orphanTx, orphanFeeRate);
4991+
RelayTransaction(orphanTx);
49974992
vWorkQueue.push_back(orphanHash);
49984993
vEraseQueue.push_back(orphanHash);
49994994
}
@@ -5046,7 +5041,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
50465041
int nDoS = 0;
50475042
if (!state.IsInvalid(nDoS) || nDoS == 0) {
50485043
LogPrintf("Force relaying tx %s from whitelisted peer=%d\n", tx.GetHash().ToString(), pfrom->id);
5049-
RelayTransaction(tx, txFeeRate);
5044+
RelayTransaction(tx);
50505045
} else {
50515046
LogPrintf("Not relaying invalid transaction %s from whitelisted peer=%d (%s)\n", tx.GetHash().ToString(), pfrom->id, FormatStateMessage(state));
50525047
}

src/main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ void PruneAndFlush();
295295

296296
/** (try to) add transaction to memory pool **/
297297
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
298-
bool* pfMissingInputs, CFeeRate* txFeeRate, bool fOverrideMempoolLimit=false, const CAmount nAbsurdFee=0);
298+
bool* pfMissingInputs, bool fOverrideMempoolLimit=false, const CAmount nAbsurdFee=0);
299299

300300
/** Convert CValidationState to a human-readable message for logging */
301301
std::string FormatStateMessage(const CValidationState &state);

src/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2069,7 +2069,7 @@ class CNetCleanup
20692069
instance_of_cnetcleanup;
20702070

20712071

2072-
void RelayTransaction(const CTransaction& tx, CFeeRate feerate)
2072+
void RelayTransaction(const CTransaction& tx)
20732073
{
20742074
CInv inv(MSG_TX, tx.GetHash());
20752075
{

src/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ class CNode
783783

784784

785785
class CTransaction;
786-
void RelayTransaction(const CTransaction& tx, CFeeRate feerate);
786+
void RelayTransaction(const CTransaction& tx);
787787

788788
/** Access to the (IP) address database (peers.dat) */
789789
class CAddrDB

src/rpc/rawtransaction.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,12 +819,11 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp)
819819
const CCoins* existingCoins = view.AccessCoins(hashTx);
820820
bool fHaveMempool = mempool.exists(hashTx);
821821
bool fHaveChain = existingCoins && existingCoins->nHeight < 1000000000;
822-
CFeeRate txFeeRate = CFeeRate(0);
823822
if (!fHaveMempool && !fHaveChain) {
824823
// push to local node and sync with wallets
825824
CValidationState state;
826825
bool fMissingInputs;
827-
if (!AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, &txFeeRate, false, nMaxRawTxFee)) {
826+
if (!AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, false, nMaxRawTxFee)) {
828827
if (state.IsInvalid()) {
829828
throw JSONRPCError(RPC_TRANSACTION_REJECTED, strprintf("%i: %s", state.GetRejectCode(), state.GetRejectReason()));
830829
} else {
@@ -837,7 +836,7 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp)
837836
} else if (fHaveChain) {
838837
throw JSONRPCError(RPC_TRANSACTION_ALREADY_IN_CHAIN, "transaction already in block chain");
839838
}
840-
RelayTransaction(tx, txFeeRate);
839+
RelayTransaction(tx);
841840

842841
return hashTx.GetHex();
843842
}

src/test/txvalidationcache_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ToMemPool(CMutableTransaction& tx)
2323
LOCK(cs_main);
2424

2525
CValidationState state;
26-
return AcceptToMemoryPool(mempool, state, tx, false, NULL, NULL, true, 0);
26+
return AcceptToMemoryPool(mempool, state, tx, false, NULL, true, 0);
2727
}
2828

2929
BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup)

src/wallet/wallet.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,9 +1272,7 @@ bool CWalletTx::RelayWalletTransaction()
12721272
{
12731273
if (GetDepthInMainChain() == 0 && !isAbandoned() && InMempool()) {
12741274
LogPrintf("Relaying wtx %s\n", GetHash().ToString());
1275-
CFeeRate feeRate;
1276-
mempool.lookupFeeRate(GetHash(), feeRate);
1277-
RelayTransaction((CTransaction)*this, feeRate);
1275+
RelayTransaction((CTransaction)*this);
12781276
return true;
12791277
}
12801278
}
@@ -3331,5 +3329,5 @@ int CMerkleTx::GetBlocksToMaturity() const
33313329
bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree, CAmount nAbsurdFee)
33323330
{
33333331
CValidationState state;
3334-
return ::AcceptToMemoryPool(mempool, state, *this, fLimitFree, NULL, NULL, false, nAbsurdFee);
3332+
return ::AcceptToMemoryPool(mempool, state, *this, fLimitFree, NULL, false, nAbsurdFee);
33353333
}

0 commit comments

Comments
 (0)