@@ -1001,15 +1001,19 @@ impl SignerDb {
1001
1001
} ) ?;
1002
1002
let mut tenure_processing_time_ms = 0_u64 ;
1003
1003
let mut tenure_start_time = None ;
1004
- for row in rows {
1004
+ let mut nmb_rows = 0 ;
1005
+ for ( i, row) in rows. enumerate ( ) {
1006
+ nmb_rows += 1 ;
1005
1007
let ( tenure_change_block, proposed_time, validation_time_ms) = row?;
1006
1008
tenure_processing_time_ms =
1007
1009
tenure_processing_time_ms. saturating_add ( validation_time_ms. unwrap_or ( 0 ) ) ;
1008
1010
tenure_start_time = Some ( proposed_time) ;
1009
1011
if tenure_change_block {
1012
+ debug ! ( "Found tenure change block {i} blocks ago in tenure {tenure}" ) ;
1010
1013
break ;
1011
1014
}
1012
1015
}
1016
+ debug ! ( "Calculated tenure extend timestamp from {nmb_rows} blocks in tenure {tenure}" ) ;
1013
1017
Ok ( (
1014
1018
tenure_start_time. unwrap_or ( get_epoch_time_secs ( ) ) ,
1015
1019
tenure_processing_time_ms,
@@ -1024,9 +1028,19 @@ impl SignerDb {
1024
1028
) -> u64 {
1025
1029
let tenure_idle_timeout_secs = tenure_idle_timeout. as_secs ( ) ;
1026
1030
let ( tenure_start_time, tenure_process_time_ms) = self . get_tenure_times ( tenure) . inspect_err ( |e| error ! ( "Error occurred calculating tenure extend timestamp: {e:?}. Defaulting to {tenure_idle_timeout_secs} from now." ) ) . unwrap_or ( ( get_epoch_time_secs ( ) , 0 ) ) ;
1027
- tenure_start_time
1031
+ // Plus (ms + 999)/1000 to round up to the nearest second
1032
+ let tenure_extend_timestamp = tenure_start_time
1028
1033
. saturating_add ( tenure_idle_timeout_secs)
1029
- . saturating_add ( tenure_process_time_ms / 1000 )
1034
+ . saturating_add ( tenure_process_time_ms. saturating_add ( 999 ) / 1000 ) ;
1035
+ debug ! ( "Calculated tenure extend timestamp" ;
1036
+ "tenure_extend_timestamp" => tenure_extend_timestamp,
1037
+ "tenure_start_time" => tenure_start_time,
1038
+ "tenure_process_time_ms" => tenure_process_time_ms,
1039
+ "tenure_idle_timeout_secs" => tenure_idle_timeout_secs,
1040
+ "tenure_extend_in" => tenure_extend_timestamp. saturating_sub( get_epoch_time_secs( ) ) ,
1041
+ "consensus_hash" => %tenure,
1042
+ ) ;
1043
+ tenure_extend_timestamp
1030
1044
}
1031
1045
}
1032
1046
0 commit comments