From 9e47bbb5c728816855e61b679136a2b57d57188b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ad=C3=A1n=20SDPC?= Date: Wed, 13 Nov 2024 14:52:23 +0100 Subject: [PATCH] ref(node): optimize protocol version derivation in epoch handler --- node/src/actors/chain_manager/handlers.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/node/src/actors/chain_manager/handlers.rs b/node/src/actors/chain_manager/handlers.rs index 19525b3e8..dd3beea5c 100644 --- a/node/src/actors/chain_manager/handlers.rs +++ b/node/src/actors/chain_manager/handlers.rs @@ -134,13 +134,14 @@ impl Handler> for ChainManager { // The best candidate must be cleared on every epoch let best_candidate = self.best_candidate.take(); - // Make sure that the protocol info in the chain state is kept up to date + // Make sure that the protocol version in the chain state is kept up to date + let expected_protocol_version = get_protocol_version(self.current_epoch); + let current_protocol_version = get_protocol_version(None); if let Some(ChainInfo { protocol, .. }) = &mut self.chain_state.chain_info { - protocol.current_version = get_protocol_version(self.current_epoch); + protocol.current_version = expected_protocol_version; } - - // Update the global protocol version state if necessary - if get_protocol_version(self.current_epoch) != get_protocol_version(None) { + // Also update the global protocol version state if necessary + if expected_protocol_version != current_protocol_version { refresh_protocol_version(current_epoch); }