@@ -372,16 +372,18 @@ replay_slot_completed( ctx_t * ctx,
372372 /* Iterate all the vote accounts to count votes towards fork choice
373373 (fd_ghost) and confirmation (fd_notar) and also reconcile our local
374374 tower with our on-chain one (fd_tower_reconcile). */
375-
376- ulong voters_cnt = get_voters ( ctx , ctx -> banks , slot_info -> bank_idx , slot_info -> slot );
375+ fd_tower_accts_remove_all ( ctx -> tower_accts );
376+ get_voters ( ctx , ctx -> banks , slot_info -> bank_idx , slot_info -> slot );
377377 fd_funk_txn_xid_t xid = { .ul = { slot_info -> slot , slot_info -> bank_idx } };
378378 ulong total_stake = 0 ;
379- for ( ulong i = 0 ; i < voters_cnt ; i ++ ) {
380- fd_pubkey_t const * vote_account_pubkey = & ctx -> tower_accts [i ].addr ;
381- fd_tower_accts_t * acct = & ctx -> tower_accts [i ];
379+ for ( fd_tower_accts_iter_t iter = fd_tower_accts_iter_init ( ctx -> tower_accts );
380+ !fd_tower_accts_iter_done ( ctx -> tower_accts , iter );
381+ fd_tower_accts_iter_next ( ctx -> tower_accts , iter ) ) {
382+ fd_pubkey_t const * vote_account_pubkey = & fd_tower_accts_iter_ele_const ( ctx -> tower_accts , iter )-> addr ; //&ctx->tower_accts[i].addr;
383+ fd_tower_accts_t * acct = fd_tower_accts_iter_ele ( ctx -> tower_accts , iter );
382384 get_vote_account_from_accdb ( ctx , vote_account_pubkey , acct , & xid );
383385
384- total_stake += ctx -> tower_accts [ i ]. stake ;
386+ total_stake += acct -> stake ;
385387 /* If this is our vote acc, reconcile with our local tower. */
386388 if ( FD_UNLIKELY ( 0 == memcmp ( & acct -> addr , ctx -> vote_account , sizeof (fd_pubkey_t ) ) ) ) fd_tower_reconcile ( ctx -> tower , ctx -> root , acct -> data );
387389
@@ -408,7 +410,7 @@ replay_slot_completed( ctx_t * ctx,
408410
409411 /* Count the vote toward ghost, notar and total_stake. */
410412
411- fd_ghost_count_vote ( ctx -> ghost , ancestor , & acct -> addr , ctx -> tower_accts [ i ]. stake , vote_slot );
413+ fd_ghost_count_vote ( ctx -> ghost , ancestor , & acct -> addr , acct -> stake , vote_slot );
412414 /* TODO count TPU vote txns towards notar */
413415 fd_forks_add_lockouts ( ctx -> forks , slot_info -> slot , & acct -> addr , acct );
414416 }
@@ -538,11 +540,6 @@ returnable_frag( ctx_t * ctx,
538540 if ( FD_LIKELY ( sig == REPLAY_SIG_SLOT_COMPLETED ) ) {
539541 fd_memcpy ( & ctx -> replay_slot_completed , fd_chunk_to_laddr ( ctx -> in [ in_idx ].mem , chunk ), sizeof (fd_replay_slot_completed_t ) );
540542 } else if ( FD_LIKELY ( sig == REPLAY_SIG_VOTE_STATE ) ) {
541- if ( FD_UNLIKELY ( fd_frag_meta_ctl_som ( ctl ) ) ) fd_tower_accts_remove_all ( ctx -> tower_accts );
542- //fd_replay_tower_t * vote_state = fd_chunk_to_laddr( ctx->in[ in_idx ].mem, chunk );
543- //fd_tower_accts_t acct = { .addr = vote_state->key };
544- //fd_memcpy( acct.data, vote_state->acc, vote_state->acc_sz );
545- //fd_tower_accts_push_tail( ctx->tower_accts, acct );
546543 if ( FD_UNLIKELY ( fd_frag_meta_ctl_eom ( ctl ) ) ) replay_slot_completed ( ctx , & ctx -> replay_slot_completed /* FIXME this seems racy */ , tsorig , stem );
547544 }
548545 return 0 ;
0 commit comments