From 5c93e35c785a7a19f8e6c762e3f1df8f8207877e Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Tue, 12 Sep 2023 11:28:16 +0200 Subject: [PATCH] fix: potential overflow (#5759) Description --- Stops a potential overflow in a log Motivation and Context --- Overflow should not be possible --- .../src/base_node/state_machine_service/states/header_sync.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base_layer/core/src/base_node/state_machine_service/states/header_sync.rs b/base_layer/core/src/base_node/state_machine_service/states/header_sync.rs index 7f85ed90c4..1c51066ea1 100644 --- a/base_layer/core/src/base_node/state_machine_service/states/header_sync.rs +++ b/base_layer/core/src/base_node/state_machine_service/states/header_sync.rs @@ -116,7 +116,7 @@ impl HeaderSyncState { let local_nci = shared.local_node_interface.clone(); synchronizer.on_rewind(move |removed| { - if let Some(fork_height) = removed.last().map(|b| b.height() - 1) { + if let Some(fork_height) = removed.last().map(|b| b.height().saturating_sub(1)) { metrics::tip_height().set(fork_height as i64); metrics::reorg(fork_height, 0, removed.len()).inc(); }