Skip to content

Commit 4b7b1bb

Browse files
committed
Sanity checks for estimates
Require at least 11 samples before giving fee/priority estimates. And have wallet-created transactions go throught the fee-sanity-check code path.
1 parent b33d1f5 commit 4b7b1bb

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,10 +1129,10 @@ int CMerkleTx::GetBlocksToMaturity() const
11291129
}
11301130

11311131

1132-
bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree)
1132+
bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree, bool fRejectInsaneFee)
11331133
{
11341134
CValidationState state;
1135-
return ::AcceptToMemoryPool(mempool, state, *this, fLimitFree, NULL);
1135+
return ::AcceptToMemoryPool(mempool, state, *this, fLimitFree, NULL, fRejectInsaneFee);
11361136
}
11371137

11381138

src/main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ class CMerkleTx : public CTransaction
452452
int GetDepthInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); }
453453
bool IsInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChainINTERNAL(pindexRet) > 0; }
454454
int GetBlocksToMaturity() const;
455-
bool AcceptToMemoryPool(bool fLimitFree=true);
455+
bool AcceptToMemoryPool(bool fLimitFree=true, bool fRejectInsaneFee=true);
456456
};
457457

458458

src/txmempool.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,13 @@ class CMinerPolicyEstimator
251251
std::sort(sortedFeeSamples.begin(), sortedFeeSamples.end(),
252252
std::greater<CFeeRate>());
253253
}
254-
if (sortedFeeSamples.size() == 0)
254+
if (sortedFeeSamples.size() < 11)
255+
{
256+
// Eleven is Gavin's Favorite Number
257+
// ... but we also take a maximum of 10 samples per block so eleven means
258+
// we're getting samples from at least two different blocks
255259
return CFeeRate(0);
260+
}
256261

257262
int nBucketSize = history.at(nBlocksToConfirm).FeeSamples();
258263

@@ -281,7 +286,7 @@ class CMinerPolicyEstimator
281286
std::sort(sortedPrioritySamples.begin(), sortedPrioritySamples.end(),
282287
std::greater<double>());
283288
}
284-
if (sortedPrioritySamples.size() == 0)
289+
if (sortedPrioritySamples.size() < 11)
285290
return -1.0;
286291

287292
int nBucketSize = history.at(nBlocksToConfirm).PrioritySamples();

0 commit comments

Comments
 (0)