@@ -12,12 +12,12 @@ use futures::future::Either;
1212use itertools:: Itertools ;
1313use witnet_data_structures:: {
1414 chain:: {
15- tapi:: ActiveWips , Block , ChainInfo , ChainState , CheckpointBeacon , ConsensusConstantsWit2 ,
15+ tapi:: ActiveWips , Block , ChainState , CheckpointBeacon , ConsensusConstantsWit2 ,
1616 DataRequestInfo , Epoch , Hash , Hashable , NodeStats , PublicKeyHash , SuperBlockVote ,
1717 SupplyInfo , SupplyInfo2 , ValueTransferOutput ,
1818 } ,
1919 error:: { ChainInfoError , TransactionError :: DataRequestNotFound } ,
20- get_protocol_version,
20+ get_protocol_info , get_protocol_version, get_protocol_version_activation_epoch ,
2121 proto:: versioning:: ProtocolVersion ,
2222 refresh_protocol_version,
2323 staking:: {
@@ -143,12 +143,8 @@ impl Handler<EpochNotification<EveryEpochPayload>> for ChainManager {
143143 // The best candidate must be cleared on every epoch
144144 let best_candidate = self . best_candidate . take ( ) ;
145145
146- // Make sure that the protocol version in the chain state is kept up to date
146+ // Update the global protocol version state if necessary
147147 let expected_protocol_version = get_protocol_version ( self . current_epoch ) ;
148- if let Some ( ChainInfo { protocol, .. } ) = & mut self . chain_state . chain_info {
149- protocol. current_version = expected_protocol_version;
150- }
151- // Also update the global protocol version state if necessary
152148 let current_protocol_version = get_protocol_version ( None ) ;
153149 if expected_protocol_version != current_protocol_version {
154150 refresh_protocol_version ( current_epoch) ;
@@ -2038,11 +2034,8 @@ impl Handler<GetSupplyInfo2> for ChainManager {
20382034 let current_staked_supply = self . chain_state . stakes . total_staked ( ) . nanowits ( ) ;
20392035
20402036 let wit1_block_reward = chain_info. consensus_constants . initial_block_reward ;
2041- let wit2_activated = chain_info. protocol . current_version == ProtocolVersion :: V2_0 ;
2042- let wit2_activation_epoch = chain_info
2043- . protocol
2044- . all_versions
2045- . get_activation_epoch ( chain_info. protocol . current_version ) ;
2037+ let wit2_activated = get_protocol_version ( None ) == ProtocolVersion :: V2_0 ;
2038+ let wit2_activation_epoch = get_protocol_version_activation_epoch ( ProtocolVersion :: V2_0 ) ;
20462039 let wit2_block_reward =
20472040 ConsensusConstantsWit2 :: default ( ) . get_validator_block_reward ( current_epoch) ;
20482041
@@ -2438,12 +2431,7 @@ impl Handler<GetProtocolInfo> for ChainManager {
24382431 type Result = <GetProtocolInfo as Message >:: Result ;
24392432
24402433 fn handle ( & mut self , _msg : GetProtocolInfo , _ctx : & mut Self :: Context ) -> Self :: Result {
2441- let chain_info = & self . chain_state . chain_info ;
2442-
2443- match chain_info {
2444- None => Ok ( None ) ,
2445- Some ( ChainInfo { protocol, .. } ) => Ok ( Some ( protocol. clone ( ) ) ) ,
2446- }
2434+ Ok ( Some ( get_protocol_info ( ) ) )
24472435 }
24482436}
24492437
0 commit comments