Skip to content

Commit 2c007c2

Browse files
committed
revert my own suggestion
1 parent 3107f61 commit 2c007c2

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

testnet/stacks-node/src/nakamoto_node/relayer.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,12 +521,29 @@ impl RelayerThread {
521521
});
522522
}
523523

524+
let mining_pkh_opt = self.get_mining_key_pkh();
524525
// a sortition happened, but we didn't win.
525-
debug!(
526-
"Relayer: did not win sortition {}, so stopping tenure",
527-
&sn.sortition
528-
);
529-
return Some(MinerDirective::StopTenure);
526+
match Self::can_continue_tenure(
527+
&self.sortdb,
528+
&mut self.chainstate,
529+
sn.consensus_hash,
530+
mining_pkh_opt,
531+
) {
532+
Ok(Some(_)) => {
533+
// we can continue our ongoing tenure, but we should give the new winning miner
534+
// a chance to send their BlockFound first.
535+
debug!("Relayer: Did not win sortition, but am mining the ongoing tenure. Allowing the new miner some time to come online before trying to continue.");
536+
self.tenure_extend_timeout = Some(Instant::now());
537+
return Some(MinerDirective::StopTenure);
538+
}
539+
Ok(None) => {
540+
return Some(MinerDirective::StopTenure);
541+
}
542+
Err(e) => {
543+
warn!("Relayer: failed to check to see if we can continue tenure: {e:?}");
544+
return Some(MinerDirective::StopTenure);
545+
}
546+
}
530547
}
531548

532549
// no sortition happened.

0 commit comments

Comments
 (0)