reorg cache fix (#3495)

* reorg cache period configurable

* fix comment

* u32 type

Co-authored-by: deevope <you@example.com>
This commit is contained in:
deevope
2020-11-25 17:59:37 +00:00
committed by GitHub
parent 3efe382e9c
commit fd5dfaaec4
4 changed files with 20 additions and 1 deletions
+9
View File
@@ -327,6 +327,15 @@ fn comments() -> HashMap<String, String> {
.to_string(),
);
retval.insert(
"reorg_cache_period".to_string(),
"
#reorg cache retention period in minute.
#the reorg cache repopulates local mempool in a reorg scenario.
"
.to_string(),
);
retval.insert(
"max_pool_size".to_string(),
"
+9
View File
@@ -107,6 +107,11 @@ pub struct PoolConfig {
#[serde(default = "default_accept_fee_base")]
pub accept_fee_base: u64,
// Reorg cache retention period in minute.
// The reorg cache repopulates local mempool in a reorg scenario.
#[serde(default = "default_reorg_cache_period")]
pub reorg_cache_period: u32,
/// Maximum capacity of the pool in number of transactions
#[serde(default = "default_max_pool_size")]
pub max_pool_size: usize,
@@ -126,6 +131,7 @@ impl Default for PoolConfig {
fn default() -> PoolConfig {
PoolConfig {
accept_fee_base: default_accept_fee_base(),
reorg_cache_period: default_reorg_cache_period(),
max_pool_size: default_max_pool_size(),
max_stempool_size: default_max_stempool_size(),
mineable_max_weight: default_mineable_max_weight(),
@@ -136,6 +142,9 @@ impl Default for PoolConfig {
fn default_accept_fee_base() -> u64 {
consensus::MILLI_GRIN
}
fn default_reorg_cache_period() -> u32 {
30
}
fn default_max_pool_size() -> usize {
50_000
}
+1
View File
@@ -167,6 +167,7 @@ where
TransactionPool::new(
PoolConfig {
accept_fee_base: 0,
reorg_cache_period: 30,
max_pool_size: 50,
max_stempool_size: 50,
mineable_max_weight: 10_000,
+1 -1
View File
@@ -767,7 +767,7 @@ where
let _ = tx_pool.reconcile_block(b);
// First "age out" any old txs in the reorg_cache.
let cutoff = Utc::now() - Duration::minutes(30);
let cutoff = Utc::now() - Duration::minutes(tx_pool.config.reorg_cache_period as i64);
tx_pool.truncate_reorg_cache(cutoff);
}