Skip to content

Commit eece408

Browse files
committed
ref(node): optimize protocol version derivation in epoch handler
1 parent 27a580b commit eece408

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

node/src/actors/chain_manager/handlers.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,14 @@ impl Handler<EpochNotification<EveryEpochPayload>> for ChainManager {
134134
// The best candidate must be cleared on every epoch
135135
let best_candidate = self.best_candidate.take();
136136

137-
// Make sure that the protocol info in the chain state is kept up to date
137+
// Make sure that the protocol version in the chain state is kept up to date
138+
let expected_protocol_version = get_protocol_version(self.current_epoch);
138139
if let Some(ChainInfo { protocol, .. }) = &mut self.chain_state.chain_info {
139-
protocol.current_version = get_protocol_version(self.current_epoch);
140+
protocol.current_version = expected_protocol_version;
140141
}
141-
142-
// Update the global protocol version state if necessary
143-
if get_protocol_version(self.current_epoch) != get_protocol_version(None) {
142+
// Also update the global protocol version state if necessary
143+
let current_protocol_version = get_protocol_version(None);
144+
if expected_protocol_version != current_protocol_version {
144145
refresh_protocol_version(current_epoch);
145146
}
146147

0 commit comments

Comments
 (0)