aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2014-06-23 10:58:59 -0400
committerGavin Andresen <gavinandresen@gmail.com>2014-07-03 13:44:56 -0400
commit4b7b1bb1ac54e067d889170757a8c45f0baaae3d (patch)
tree137436a4b855fd776d59f019e5a4d304c9253424 /src
parentb33d1f5ee512da5719b793b3867f75f1eea5cf52 (diff)
downloadbitcoin-4b7b1bb1ac54e067d889170757a8c45f0baaae3d.tar.xz
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.
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp4
-rw-r--r--src/main.h2
-rw-r--r--src/txmempool.cpp9
3 files changed, 10 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 6be1a29c6c..d1ddf1600d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1129,10 +1129,10 @@ int CMerkleTx::GetBlocksToMaturity() const
}
-bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree)
+bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree, bool fRejectInsaneFee)
{
CValidationState state;
- return ::AcceptToMemoryPool(mempool, state, *this, fLimitFree, NULL);
+ return ::AcceptToMemoryPool(mempool, state, *this, fLimitFree, NULL, fRejectInsaneFee);
}
diff --git a/src/main.h b/src/main.h
index e8df17dda0..4c7b7fd8d4 100644
--- a/src/main.h
+++ b/src/main.h
@@ -452,7 +452,7 @@ public:
int GetDepthInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); }
bool IsInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChainINTERNAL(pindexRet) > 0; }
int GetBlocksToMaturity() const;
- bool AcceptToMemoryPool(bool fLimitFree=true);
+ bool AcceptToMemoryPool(bool fLimitFree=true, bool fRejectInsaneFee=true);
};
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 97a426dd35..0a8ad96aac 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -251,8 +251,13 @@ public:
std::sort(sortedFeeSamples.begin(), sortedFeeSamples.end(),
std::greater<CFeeRate>());
}
- if (sortedFeeSamples.size() == 0)
+ if (sortedFeeSamples.size() < 11)
+ {
+ // Eleven is Gavin's Favorite Number
+ // ... but we also take a maximum of 10 samples per block so eleven means
+ // we're getting samples from at least two different blocks
return CFeeRate(0);
+ }
int nBucketSize = history.at(nBlocksToConfirm).FeeSamples();
@@ -281,7 +286,7 @@ public:
std::sort(sortedPrioritySamples.begin(), sortedPrioritySamples.end(),
std::greater<double>());
}
- if (sortedPrioritySamples.size() == 0)
+ if (sortedPrioritySamples.size() < 11)
return -1.0;
int nBucketSize = history.at(nBlocksToConfirm).PrioritySamples();