Skip to content

Commit d24657e

Browse files
author
Hyunsik Jeong
committed
Add flag to disable reseal timer
1 parent 1534345 commit d24657e

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

codechain/codechain.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ args:
192192
takes_value: true
193193
conflicts_with:
194194
- no-miner
195+
- no-reseal-timer:
196+
long: no-reseal-timer
197+
help: Do not use reseal timer.
198+
takes_value: false
199+
conflicts_with:
200+
- no-miner
195201
- work-queue-size:
196202
long: work-queue-size
197203
value_name: ITEMS

codechain/config/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ impl Config {
8383
reseal_on_external_parcel,
8484
reseal_min_period: Duration::from_millis(self.mining.reseal_min_period.unwrap()),
8585
reseal_max_period: Duration::from_millis(self.mining.reseal_max_period.unwrap()),
86+
no_reseal_timer: self.mining.no_reseal_timer.unwrap(),
8687
work_queue_size: self.mining.work_queue_size.unwrap(),
8788
})
8889
}
@@ -218,6 +219,7 @@ pub struct Mining {
218219
pub reseal_on_txs: Option<String>,
219220
pub reseal_min_period: Option<u64>,
220221
pub reseal_max_period: Option<u64>,
222+
pub no_reseal_timer: Option<bool>,
221223
pub work_queue_size: Option<usize>,
222224
}
223225

@@ -375,6 +377,9 @@ impl Mining {
375377
if other.reseal_max_period.is_some() {
376378
self.reseal_max_period = other.reseal_max_period;
377379
}
380+
if other.no_reseal_timer.is_some() {
381+
self.no_reseal_timer = other.no_reseal_timer;
382+
}
378383
if other.work_queue_size.is_some() {
379384
self.work_queue_size = other.work_queue_size;
380385
}
@@ -412,6 +417,9 @@ impl Mining {
412417
if let Some(reseal_max_period) = matches.value_of("reseal-max-period") {
413418
self.reseal_max_period = Some(reseal_max_period.parse().map_err(|_| "Invalid period")?);
414419
}
420+
if matches.is_present("no-reseal-timer") {
421+
self.no_reseal_timer = Some(true);
422+
}
415423
if let Some(work_queue_size) = matches.value_of("work-queue-size") {
416424
self.work_queue_size = Some(work_queue_size.parse().map_err(|_| "Invalid size")?);
417425
}

core/src/miner/miner.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ pub struct MinerOptions {
6161
pub reseal_min_period: Duration,
6262
/// Maximum period between blocks (enables force sealing after that).
6363
pub reseal_max_period: Duration,
64+
/// Disable the reseal timer
65+
pub no_reseal_timer: bool,
6466
/// Maximum size of the mem pool.
6567
pub mem_pool_size: usize,
6668
/// Maximum memory usage of parcels in the queue (current / future).
@@ -78,6 +80,7 @@ impl Default for MinerOptions {
7880
reseal_on_own_parcel: true,
7981
reseal_min_period: Duration::from_secs(2),
8082
reseal_max_period: Duration::from_secs(120),
83+
no_reseal_timer: false,
8184
mem_pool_size: 8192,
8285
mem_pool_memory_limit: Some(2 * 1024 * 1024),
8386
work_queue_size: 20,
@@ -745,13 +748,17 @@ impl MinerService for Miner {
745748
self.prepare_work(block, original_work_hash);
746749
// Set the reseal max timer, for creating empty blocks every reseal_max_period
747750
// Not related to next_mandatory_reseal, which is used in seal_and_import_block_internally
748-
chain.set_max_timer();
751+
if !self.options.no_reseal_timer {
752+
chain.set_max_timer();
753+
}
749754
}
750755
}
751756

752757
// Sealing successful
753758
*self.next_allowed_reseal.lock() = Instant::now() + self.options.reseal_min_period;
754-
chain.set_min_timer();
759+
if !self.options.no_reseal_timer {
760+
chain.set_min_timer();
761+
}
755762
}
756763
}
757764

0 commit comments

Comments
 (0)