Browse Source

Fix calling mempool directly, instead of pool, in ATMP

0.13
Matt Corallo 9 years ago
parent
commit
9c9b66f771
  1. 21
      src/main.cpp
  2. 4
      src/txmempool.cpp
  3. 4
      src/txmempool.h

21
src/main.cpp

@ -740,17 +740,14 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
return true; return true;
} }
CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree) CAmount GetMinRelayFee(const CTransaction& tx, const CTxMemPool& pool, unsigned int nBytes, bool fAllowFree)
{ {
{ uint256 hash = tx.GetHash();
LOCK(mempool.cs); double dPriorityDelta = 0;
uint256 hash = tx.GetHash(); CAmount nFeeDelta = 0;
double dPriorityDelta = 0; pool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta);
CAmount nFeeDelta = 0; if (dPriorityDelta > 0 || nFeeDelta > 0)
mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta); return 0;
if (dPriorityDelta > 0 || nFeeDelta > 0)
return 0;
}
CAmount nMinFee = ::minRelayTxFee.GetFee(nBytes); CAmount nMinFee = ::minRelayTxFee.GetFee(nBytes);
@ -879,11 +876,11 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
CAmount nFees = nValueIn-nValueOut; CAmount nFees = nValueIn-nValueOut;
double dPriority = view.GetPriority(tx, chainActive.Height()); double dPriority = view.GetPriority(tx, chainActive.Height());
CTxMemPoolEntry entry(tx, nFees, GetTime(), dPriority, chainActive.Height(), mempool.HasNoInputsOf(tx)); CTxMemPoolEntry entry(tx, nFees, GetTime(), dPriority, chainActive.Height(), pool.HasNoInputsOf(tx));
unsigned int nSize = entry.GetTxSize(); unsigned int nSize = entry.GetTxSize();
// Don't accept it if it can't get into a block // Don't accept it if it can't get into a block
CAmount txMinFee = GetMinRelayFee(tx, nSize, true); CAmount txMinFee = GetMinRelayFee(tx, pool, nSize, true);
if (fLimitFree && nFees < txMinFee) if (fLimitFree && nFees < txMinFee)
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "insufficient fee", false, return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "insufficient fee", false,
strprintf("%d < %d", nFees, txMinFee)); strprintf("%d < %d", nFees, txMinFee));

4
src/txmempool.cpp

@ -735,10 +735,10 @@ void CTxMemPool::PrioritiseTransaction(const uint256 hash, const string strHash,
LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", strHash, dPriorityDelta, FormatMoney(nFeeDelta)); LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", strHash, dPriorityDelta, FormatMoney(nFeeDelta));
} }
void CTxMemPool::ApplyDeltas(const uint256 hash, double &dPriorityDelta, CAmount &nFeeDelta) void CTxMemPool::ApplyDeltas(const uint256 hash, double &dPriorityDelta, CAmount &nFeeDelta) const
{ {
LOCK(cs); LOCK(cs);
std::map<uint256, std::pair<double, CAmount> >::iterator pos = mapDeltas.find(hash); std::map<uint256, std::pair<double, CAmount> >::const_iterator pos = mapDeltas.find(hash);
if (pos == mapDeltas.end()) if (pos == mapDeltas.end())
return; return;
const std::pair<double, CAmount> &deltas = pos->second; const std::pair<double, CAmount> &deltas = pos->second;

4
src/txmempool.h

@ -83,7 +83,7 @@ public:
const CTransaction& GetTx() const { return this->tx; } const CTransaction& GetTx() const { return this->tx; }
double GetPriority(unsigned int currentHeight) const; double GetPriority(unsigned int currentHeight) const;
CAmount GetFee() const { return nFee; } const CAmount& GetFee() const { return nFee; }
size_t GetTxSize() const { return nTxSize; } size_t GetTxSize() const { return nTxSize; }
int64_t GetTime() const { return nTime; } int64_t GetTime() const { return nTime; }
unsigned int GetHeight() const { return nHeight; } unsigned int GetHeight() const { return nHeight; }
@ -371,7 +371,7 @@ public:
/** Affect CreateNewBlock prioritisation of transactions */ /** Affect CreateNewBlock prioritisation of transactions */
void PrioritiseTransaction(const uint256 hash, const std::string strHash, double dPriorityDelta, const CAmount& nFeeDelta); void PrioritiseTransaction(const uint256 hash, const std::string strHash, double dPriorityDelta, const CAmount& nFeeDelta);
void ApplyDeltas(const uint256 hash, double &dPriorityDelta, CAmount &nFeeDelta); void ApplyDeltas(const uint256 hash, double &dPriorityDelta, CAmount &nFeeDelta) const;
void ClearPrioritisation(const uint256 hash); void ClearPrioritisation(const uint256 hash);
public: public:

Loading…
Cancel
Save