@@ -71,9 +71,9 @@ impl GlobalStateEvaluator {
71
71
fn determine_latest_supported_signer_protocol_version (
72
72
& mut self ,
73
73
local_address : StacksAddress ,
74
- local_update : StateMachineUpdateMessage ,
74
+ local_update : & StateMachineUpdateMessage ,
75
75
) -> Option < u64 > {
76
- self . insert_update ( local_address, local_update) ;
76
+ self . insert_update ( local_address, local_update. clone ( ) ) ;
77
77
let mut protocol_versions = HashMap :: new ( ) ;
78
78
for ( address, update) in & self . address_updates {
79
79
let Some ( weight) = self . address_weights . get ( address) else {
@@ -101,9 +101,9 @@ impl GlobalStateEvaluator {
101
101
pub fn determine_global_burn_view (
102
102
& mut self ,
103
103
local_address : StacksAddress ,
104
- local_update : StateMachineUpdateMessage ,
104
+ local_update : & StateMachineUpdateMessage ,
105
105
) -> Option < ( ConsensusHash , u64 ) > {
106
- self . insert_update ( local_address, local_update) ;
106
+ self . insert_update ( local_address, local_update. clone ( ) ) ;
107
107
let mut burn_blocks = HashMap :: new ( ) ;
108
108
for ( address, update) in & self . address_updates {
109
109
let Some ( weight) = self . address_weights . get ( address) else {
@@ -126,11 +126,11 @@ impl GlobalStateEvaluator {
126
126
None
127
127
}
128
128
129
- /// Check if there is an agreed upon global current miner viewpoint
129
+ /// Check if there is an agreed upon global state
130
130
pub fn determine_global_state (
131
131
& mut self ,
132
132
local_address : StacksAddress ,
133
- local_update : StateMachineUpdateMessage ,
133
+ local_update : & StateMachineUpdateMessage ,
134
134
) -> Option < SignerStateMachine > {
135
135
let active_signer_protocol_version =
136
136
self . determine_latest_supported_signer_protocol_version ( local_address, local_update) ?;
@@ -169,12 +169,12 @@ impl GlobalStateEvaluator {
169
169
& mut self ,
170
170
signerdb : & mut SignerDb ,
171
171
local_address : StacksAddress ,
172
- local_update : StateMachineUpdateMessage ,
172
+ local_update : & StateMachineUpdateMessage ,
173
173
) -> Option < StateMachineUpdateMinerState > {
174
174
let StateMachineUpdateContent :: V0 {
175
175
burn_block : current_burn_block,
176
176
..
177
- } = local_update. content . clone ( ) ;
177
+ } = local_update. content ;
178
178
let ( global_burn_view, _) = self . determine_global_burn_view ( local_address, local_update) ?;
179
179
if current_burn_block != global_burn_view {
180
180
return None ;
@@ -194,8 +194,7 @@ impl GlobalStateEvaluator {
194
194
continue ;
195
195
}
196
196
197
- let StateMachineUpdateMinerState :: ActiveMiner { tenure_id, .. } = current_miner. clone ( )
198
- else {
197
+ let StateMachineUpdateMinerState :: ActiveMiner { tenure_id, .. } = current_miner else {
199
198
continue ;
200
199
} ;
201
200
@@ -204,7 +203,7 @@ impl GlobalStateEvaluator {
204
203
205
204
if * entry >= self . total_weight * 3 / 10 {
206
205
let nmb_blocks = signerdb
207
- . get_globally_accepted_block_count_in_tenure ( & tenure_id)
206
+ . get_globally_accepted_block_count_in_tenure ( tenure_id)
208
207
. unwrap_or ( 0 ) ;
209
208
if nmb_blocks > 0 || self . reached_agreement ( * entry) {
210
209
return Some ( current_miner. clone ( ) ) ;
@@ -762,7 +761,7 @@ impl LocalStateMachine {
762
761
let old_protocol_version = local_update. active_signer_protocol_version ;
763
762
// First check if we should update our active protocol version
764
763
let active_signer_protocol_version = eval
765
- . determine_latest_supported_signer_protocol_version ( local_address, local_update. clone ( ) )
764
+ . determine_latest_supported_signer_protocol_version ( local_address, & local_update)
766
765
. unwrap_or ( old_protocol_version) ;
767
766
768
767
let StateMachineUpdateContent :: V0 {
@@ -789,8 +788,7 @@ impl LocalStateMachine {
789
788
}
790
789
791
790
// Check if we should also capitulate our miner viewpoint
792
- let Some ( new_miner) =
793
- eval. capitulate_miner_view ( signerdb, local_address, local_update. clone ( ) )
791
+ let Some ( new_miner) = eval. capitulate_miner_view ( signerdb, local_address, & local_update)
794
792
else {
795
793
return ;
796
794
} ;
@@ -884,14 +882,7 @@ mod tests {
884
882
. clone ( ) ;
885
883
assert_eq ! (
886
884
global_eval
887
- . determine_latest_supported_signer_protocol_version(
888
- local_address,
889
- global_eval
890
- . address_updates
891
- . get( & local_address)
892
- . unwrap( )
893
- . clone( ) ,
894
- )
885
+ . determine_latest_supported_signer_protocol_version( local_address, & local_update, )
895
886
. unwrap( ) ,
896
887
local_update. local_supported_signer_protocol_version
897
888
) ;
@@ -926,7 +917,7 @@ mod tests {
926
917
927
918
assert_eq ! (
928
919
global_eval
929
- . determine_latest_supported_signer_protocol_version( local_address, local_update)
920
+ . determine_latest_supported_signer_protocol_version( local_address, & local_update)
930
921
. unwrap( ) ,
931
922
local_supported_signer_protocol_version
932
923
) ;
@@ -946,7 +937,7 @@ mod tests {
946
937
947
938
assert_eq ! (
948
939
global_eval
949
- . determine_latest_supported_signer_protocol_version( local_address, local_update)
940
+ . determine_latest_supported_signer_protocol_version( local_address, & local_update)
950
941
. unwrap( ) ,
951
942
local_supported_signer_protocol_version + 1
952
943
) ;
@@ -977,7 +968,7 @@ mod tests {
977
968
978
969
assert_eq ! (
979
970
global_eval
980
- . determine_global_burn_view( local_address, local_update. clone ( ) , )
971
+ . determine_global_burn_view( local_address, & local_update)
981
972
. unwrap( ) ,
982
973
( burn_block, burn_block_height)
983
974
) ;
@@ -999,15 +990,15 @@ mod tests {
999
990
1000
991
assert ! (
1001
992
global_eval
1002
- . determine_global_burn_view( local_address, local_update, )
993
+ . determine_global_burn_view( local_address, & local_update)
1003
994
. is_none( ) ,
1004
995
"We should not have reached agreement on the burn block height"
1005
996
) ;
1006
997
1007
998
// Let's tip the scales over to burn block height + 1
1008
999
assert_eq ! (
1009
1000
global_eval
1010
- . determine_global_burn_view( local_address, new_update, )
1001
+ . determine_global_burn_view( local_address, & new_update)
1011
1002
. unwrap( ) ,
1012
1003
( burn_block, burn_block_height. wrapping_add( 1 ) )
1013
1004
) ;
@@ -1045,7 +1036,7 @@ mod tests {
1045
1036
1046
1037
assert_eq ! (
1047
1038
global_eval
1048
- . determine_global_state( local_address, local_update. clone ( ) , )
1039
+ . determine_global_state( local_address, & local_update)
1049
1040
. unwrap( ) ,
1050
1041
state_machine
1051
1042
) ;
@@ -1075,7 +1066,7 @@ mod tests {
1075
1066
1076
1067
assert ! (
1077
1068
global_eval
1078
- . determine_global_state( local_address, local_update, )
1069
+ . determine_global_state( local_address, & local_update)
1079
1070
. is_none( ) ,
1080
1071
"We should have a disagreement about the current miner"
1081
1072
) ;
@@ -1090,7 +1081,7 @@ mod tests {
1090
1081
// Let's tip the scales over to a different miner
1091
1082
assert_eq ! (
1092
1083
global_eval
1093
- . determine_global_state( local_address, new_update, )
1084
+ . determine_global_state( local_address, & new_update)
1094
1085
. unwrap( ) ,
1095
1086
state_machine
1096
1087
)
@@ -1152,7 +1143,7 @@ mod tests {
1152
1143
// Let's update only our own view: the evaluator will tell me to revert my viewpoint to the original miner
1153
1144
assert_eq ! (
1154
1145
global_eval
1155
- . capitulate_miner_view( & mut db, local_address, new_update. clone ( ) )
1146
+ . capitulate_miner_view( & mut db, local_address, & new_update)
1156
1147
. unwrap( ) ,
1157
1148
current_miner
1158
1149
) ;
@@ -1165,7 +1156,7 @@ mod tests {
1165
1156
}
1166
1157
assert ! (
1167
1158
global_eval
1168
- . capitulate_miner_view( & mut db, local_address, new_update. clone ( ) )
1159
+ . capitulate_miner_view( & mut db, local_address, & new_update)
1169
1160
. is_none( ) ,
1170
1161
"Evaluator should have been unable to determine a majority view and return none"
1171
1162
) ;
@@ -1177,7 +1168,7 @@ mod tests {
1177
1168
// Now that the blocking minority references a tenure which would actually get reorged, lets capitulate to their view
1178
1169
assert_eq ! (
1179
1170
global_eval
1180
- . capitulate_miner_view( & mut db, local_address, new_update)
1171
+ . capitulate_miner_view( & mut db, local_address, & new_update)
1181
1172
. unwrap( ) ,
1182
1173
new_miner
1183
1174
) ;
0 commit comments