Skip to content

Commit 916d01a

Browse files
committed
fix: mine microblocks if there are no *recent* attachable blocks (i.e. less than 10 minutes present)
1 parent 7395803 commit 916d01a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

testnet/stacks-node/src/neon_node.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,13 @@ fn try_mine_microblock(
436436
if microblock_miner.last_mined + (microblock_miner.frequency as u128)
437437
< get_epoch_time_ms()
438438
{
439-
// opportunistically try and mine, but only if there's no attachable blocks
440-
let num_attachable =
441-
StacksChainState::count_attachable_staging_blocks(chainstate.db(), 1, 0)?;
439+
// opportunistically try and mine, but only if there are no attachable blocks in
440+
// recent history (i.e. in the last 10 minutes)
441+
let num_attachable = StacksChainState::count_attachable_staging_blocks(
442+
chainstate.db(),
443+
1,
444+
get_epoch_time_secs() - 600,
445+
)?;
442446
if num_attachable == 0 {
443447
match mine_one_microblock(&mut microblock_miner, sortdb, chainstate, &mem_pool)
444448
{
@@ -453,6 +457,8 @@ fn try_mine_microblock(
453457
warn!("Failed to mine one microblock: {:?}", &e);
454458
}
455459
}
460+
} else {
461+
debug!("Will not mine microblocks yet -- have {} attachable blocks that arrived in the last 10 minutes", num_attachable);
456462
}
457463
}
458464
microblock_miner.last_mined = get_epoch_time_ms();

0 commit comments

Comments
 (0)