@@ -91,16 +91,16 @@ simulate_vote( fd_tower_t const * tower, ulong slot ) {
91
91
int
92
92
fd_tower_lockout_check ( fd_tower_t const * tower ,
93
93
fd_ghost_t const * ghost ,
94
- ulong switch_slot ,
95
- fd_hash_t const * hash_id ) {
94
+ ulong slot ,
95
+ fd_hash_t const * block_id ) {
96
96
#if FD_TOWER_USE_HANDHOLDING
97
97
FD_TEST ( !fd_tower_votes_empty ( tower ) ); /* caller error */
98
98
#endif
99
99
100
100
/* Simulate a vote to pop off all the votes that have been expired at
101
101
the top of the tower. */
102
102
103
- ulong cnt = simulate_vote ( tower , switch_slot );
103
+ ulong cnt = simulate_vote ( tower , slot );
104
104
105
105
/* By definition, all votes in the tower must be for the same fork, so
106
106
check if the previous vote (ie. the last vote in the tower) is on
@@ -115,18 +115,19 @@ fd_tower_lockout_check( fd_tower_t const * tower,
115
115
fd_tower_vote_t const * vote = fd_tower_votes_peek_index_const ( tower , cnt - 1 );
116
116
fd_ghost_ele_t const * root = fd_ghost_root_const ( ghost );
117
117
118
- int lockout_check = vote -> slot < root -> slot ||
119
- fd_ghost_is_ancestor ( ghost , fd_ghost_hash ( ghost , vote -> slot ), hash_id );
120
- FD_LOG_NOTICE (( "[fd_tower_lockout_check] ok? %d. top: (slot: %lu, conf: %lu). switch: %lu." , lockout_check , vote -> slot , vote -> conf , switch_slot ));
118
+ int lockout_check = slot <= vote -> slot ||
119
+ vote -> slot < root -> slot ||
120
+ fd_ghost_is_ancestor ( ghost , fd_ghost_hash ( ghost , vote -> slot ), block_id );
121
+ FD_LOG_NOTICE (( "[fd_tower_lockout_check] ok? %d. top: (slot: %lu, conf: %lu). switch: %lu." , lockout_check , vote -> slot , vote -> conf , slot ));
121
122
return lockout_check ;
122
123
}
123
124
124
125
int
125
126
fd_tower_switch_check ( fd_tower_t const * tower ,
126
127
fd_epoch_t const * epoch ,
127
128
fd_ghost_t const * ghost ,
128
- ulong switch_slot ,
129
- fd_hash_t const * switch_hash_id ) {
129
+ ulong slot ,
130
+ fd_hash_t const * block_id ) {
130
131
#if FD_TOWER_USE_HANDHOLDING
131
132
FD_TEST ( !fd_tower_votes_empty ( tower ) ); /* caller error */
132
133
#endif
@@ -169,12 +170,12 @@ fd_tower_switch_check( fd_tower_t const * tower,
169
170
*/
170
171
171
172
#if FD_TOWER_USE_HANDHOLDING
172
- FD_TEST ( !fd_ghost_is_ancestor ( ghost , fd_ghost_hash ( ghost , vote -> slot ), switch_hash_id ) );
173
+ FD_TEST ( !fd_ghost_is_ancestor ( ghost , fd_ghost_hash ( ghost , vote -> slot ), block_id ) );
173
174
#endif
174
175
fd_hash_t const * vote_block_id = fd_ghost_hash ( ghost , vote -> slot );
175
176
fd_ghost_hash_map_t const * maph = fd_ghost_hash_map_const ( ghost );
176
177
fd_ghost_ele_t const * pool = fd_ghost_pool_const ( ghost );
177
- fd_ghost_ele_t const * gca = fd_ghost_gca ( ghost , vote_block_id , switch_hash_id );
178
+ fd_ghost_ele_t const * gca = fd_ghost_gca ( ghost , vote_block_id , block_id );
178
179
ulong gca_idx = fd_ghost_hash_map_idx_query_const ( maph , & gca -> key , ULONG_MAX , pool );
179
180
180
181
/* gca_child is our latest_vote slot's ancestor that is also a direct
@@ -196,7 +197,7 @@ fd_tower_switch_check( fd_tower_t const * tower,
196
197
}
197
198
198
199
double switch_pct = (double )switch_stake / (double )epoch -> total_stake ;
199
- FD_LOG_DEBUG (( "[%s] ok? %d. top: %lu. switch: %lu. switch stake: %.0lf%%." , __func__ , switch_pct > SWITCH_PCT , fd_tower_votes_peek_tail_const ( tower )-> slot , switch_slot , switch_pct * 100.0 ));
200
+ FD_LOG_DEBUG (( "[%s] ok? %d. top: %lu. switch: %lu. switch stake: %.0lf%%." , __func__ , switch_pct > SWITCH_PCT , fd_tower_votes_peek_tail_const ( tower )-> slot , slot , switch_pct * 100.0 ));
200
201
return switch_pct > SWITCH_PCT ;
201
202
}
202
203
0 commit comments