mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-01-12 22:43:42 +08:00
Merge pull request #4795 from stacks-network/feat/next-initiative-delay-config
feat: add a next_initiative_delay config
This commit is contained in:
@@ -1795,6 +1795,13 @@ pub struct NodeConfig {
|
||||
pub max_microblocks: u64,
|
||||
pub wait_time_for_microblocks: u64,
|
||||
pub wait_time_for_blocks: u64,
|
||||
/// Controls how frequently, in milliseconds, the nakamoto miner's relay thread acts on its own initiative
|
||||
/// (as opposed to responding to an event from the networking thread, etc.). This is roughly
|
||||
/// how frequently the miner checks if a new burnchain block has been processed.
|
||||
///
|
||||
/// Default value of 10 seconds is reasonable in mainnet (where bitcoin blocks are ~10 minutes),
|
||||
/// but environments where burn blocks are more frequent may want to decrease this value.
|
||||
pub next_initiative_delay: u64,
|
||||
pub prometheus_bind: Option<String>,
|
||||
pub marf_cache_strategy: Option<String>,
|
||||
pub marf_defer_hashing: bool,
|
||||
@@ -2080,6 +2087,7 @@ impl Default for NodeConfig {
|
||||
max_microblocks: u16::MAX as u64,
|
||||
wait_time_for_microblocks: 30_000,
|
||||
wait_time_for_blocks: 30_000,
|
||||
next_initiative_delay: 10_000,
|
||||
prometheus_bind: None,
|
||||
marf_cache_strategy: None,
|
||||
marf_defer_hashing: true,
|
||||
@@ -2530,6 +2538,7 @@ pub struct NodeConfigFile {
|
||||
pub max_microblocks: Option<u64>,
|
||||
pub wait_time_for_microblocks: Option<u64>,
|
||||
pub wait_time_for_blocks: Option<u64>,
|
||||
pub next_initiative_delay: Option<u64>,
|
||||
pub prometheus_bind: Option<String>,
|
||||
pub marf_cache_strategy: Option<String>,
|
||||
pub marf_defer_hashing: Option<bool>,
|
||||
@@ -2590,6 +2599,9 @@ impl NodeConfigFile {
|
||||
wait_time_for_blocks: self
|
||||
.wait_time_for_blocks
|
||||
.unwrap_or(default_node_config.wait_time_for_blocks),
|
||||
next_initiative_delay: self
|
||||
.next_initiative_delay
|
||||
.unwrap_or(default_node_config.next_initiative_delay),
|
||||
prometheus_bind: self.prometheus_bind,
|
||||
marf_cache_strategy: self.marf_cache_strategy,
|
||||
marf_defer_hashing: self
|
||||
|
||||
@@ -190,8 +190,10 @@ impl RelayerThread {
|
||||
|
||||
let bitcoin_controller = BitcoinRegtestController::new_dummy(config.clone());
|
||||
|
||||
let next_initiative_delay = config.node.next_initiative_delay;
|
||||
|
||||
RelayerThread {
|
||||
config: config,
|
||||
config,
|
||||
sortdb,
|
||||
chainstate,
|
||||
mempool,
|
||||
@@ -215,7 +217,7 @@ impl RelayerThread {
|
||||
|
||||
miner_thread: None,
|
||||
is_miner,
|
||||
next_initiative: Instant::now() + Duration::from_secs(10),
|
||||
next_initiative: Instant::now() + Duration::from_millis(next_initiative_delay),
|
||||
last_committed: None,
|
||||
}
|
||||
}
|
||||
@@ -819,10 +821,12 @@ impl RelayerThread {
|
||||
pub fn main(mut self, relay_rcv: Receiver<RelayerDirective>) {
|
||||
debug!("relayer thread ID is {:?}", std::thread::current().id());
|
||||
|
||||
self.next_initiative = Instant::now() + Duration::from_secs(10);
|
||||
self.next_initiative =
|
||||
Instant::now() + Duration::from_millis(self.config.node.next_initiative_delay);
|
||||
while self.globals.keep_running() {
|
||||
let directive = if Instant::now() >= self.next_initiative {
|
||||
self.next_initiative = Instant::now() + Duration::from_secs(10);
|
||||
self.next_initiative =
|
||||
Instant::now() + Duration::from_millis(self.config.node.next_initiative_delay);
|
||||
self.initiative()
|
||||
} else {
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user