@@ -12,12 +12,12 @@ use futures::future::Either;
12
12
use itertools:: Itertools ;
13
13
use witnet_data_structures:: {
14
14
chain:: {
15
- tapi:: ActiveWips , Block , ChainInfo , ChainState , CheckpointBeacon , ConsensusConstantsWit2 ,
15
+ tapi:: ActiveWips , Block , ChainState , CheckpointBeacon , ConsensusConstantsWit2 ,
16
16
DataRequestInfo , Epoch , Hash , Hashable , NodeStats , PublicKeyHash , SuperBlockVote ,
17
17
SupplyInfo , SupplyInfo2 , ValueTransferOutput ,
18
18
} ,
19
19
error:: { ChainInfoError , TransactionError :: DataRequestNotFound } ,
20
- get_protocol_version,
20
+ get_protocol_info , get_protocol_version, get_protocol_version_activation_epoch ,
21
21
proto:: versioning:: ProtocolVersion ,
22
22
refresh_protocol_version,
23
23
staking:: {
@@ -143,12 +143,8 @@ impl Handler<EpochNotification<EveryEpochPayload>> for ChainManager {
143
143
// The best candidate must be cleared on every epoch
144
144
let best_candidate = self . best_candidate . take ( ) ;
145
145
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
147
147
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
152
148
let current_protocol_version = get_protocol_version ( None ) ;
153
149
if expected_protocol_version != current_protocol_version {
154
150
refresh_protocol_version ( current_epoch) ;
@@ -2038,11 +2034,8 @@ impl Handler<GetSupplyInfo2> for ChainManager {
2038
2034
let current_staked_supply = self . chain_state . stakes . total_staked ( ) . nanowits ( ) ;
2039
2035
2040
2036
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 ) ;
2046
2039
let wit2_block_reward =
2047
2040
ConsensusConstantsWit2 :: default ( ) . get_validator_block_reward ( current_epoch) ;
2048
2041
@@ -2438,12 +2431,7 @@ impl Handler<GetProtocolInfo> for ChainManager {
2438
2431
type Result = <GetProtocolInfo as Message >:: Result ;
2439
2432
2440
2433
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 ( ) ) )
2447
2435
}
2448
2436
}
2449
2437
0 commit comments