Skip to content

Commit 7b265f7

Browse files
committed
feat: make tenure idle timestamps monotonically increase
This is just in case the miner receives a signature for an old block, it will not adjust the timestamp down from the latest is already had seen.
1 parent d828159 commit 7b265f7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,16 @@ impl StackerDBListener {
433433
.signer_idle_timestamps
434434
.lock()
435435
.expect("FATAL: failed to lock idle timestamps");
436+
437+
// Check the current timestamp for the given signer_pubkey
438+
if let Some(existing_info) = idle_timestamps.get(&signer_pubkey) {
439+
// Only update if the new timestamp is greater
440+
if timestamp <= existing_info.timestamp {
441+
return; // Exit early if the new timestamp is not greater
442+
}
443+
}
444+
445+
// Update the map with the new timestamp and weight
436446
let timestamp_info = TimestampInfo { timestamp, weight };
437447
idle_timestamps.insert(signer_pubkey, timestamp_info);
438448
}

0 commit comments

Comments
 (0)