Skip to content

Commit 4fd5e43

Browse files
committed
gui: vote slot message
1 parent 31e1c3a commit 4fd5e43

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

book/api/websocket.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,14 @@ The largest slot for which the validator sent out a repair request.
293293
This slot has the same problem as `summary.turbine_slot` (it might
294294
sporadically become unboundedly large) and provides the same guarantees.
295295

296+
#### `summary.vote_slot`
297+
| frequency | type | example |
298+
|-----------------|----------------|---------|
299+
| *Once* + *Live* | `number\|null` | `100` |
300+
301+
The most recent replayed slot this node was in the process of voting on.
302+
May be `null` at startup if voting has not started.
303+
296304
#### `summary.caught_up_slot`
297305
| frequency | type | example |
298306
|-----------------|----------------|---------|

src/disco/gui/fd_gui_peers.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ fd_gui_peers_handle_vote_update( fd_gui_peers_ctx_t * peers,
675675
fd_gui_peers_vote_t * votes,
676676
ulong vote_cnt,
677677
long now,
678+
fd_pubkey_t * identity,
678679
char country_code_map[ static 512 ][ 3 ] ) {
679680
(void)now;
680681
fd_gui_peers_vote_t * votes_sorted = votes;
@@ -718,6 +719,12 @@ fd_gui_peers_handle_vote_update( fd_gui_peers_ctx_t * peers,
718719
for( ulong i=0UL; i<vote_cnt; i++ ) {
719720
if( FD_UNLIKELY( votes_sorted[ i ].stake==ULONG_MAX ) ) continue;
720721

722+
if( FD_UNLIKELY( !memcmp( &votes_sorted[ i ].node_account, identity->uc, sizeof(fd_pubkey_t) ) && peers->slot_voted!=votes_sorted[ i ].last_vote_slot ) ) {
723+
peers->slot_voted = votes_sorted[ i ].last_vote_slot;
724+
fd_gui_peers_printf_vote_slot( peers );
725+
fd_http_server_ws_broadcast( peers->http );
726+
}
727+
721728
ulong peer_idx = fd_gui_peers_node_pubkey_map_idx_query( peers->node_pubkey_map, &votes_sorted[ i ].node_account, ULONG_MAX, peers->contact_info_table );
722729
if( FD_UNLIKELY( peer_idx==ULONG_MAX ) ) continue; /* peer not on gossip */
723730

src/disco/gui/fd_gui_peers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ struct fd_gui_peers_ctx {
337337
fd_gui_peers_gossip_stats_t gossip_stats [ 1 ];
338338
fd_gui_peers_node_t contact_info_table[ FD_CONTACT_INFO_TABLE_SIZE ];
339339

340+
ulong slot_voted; /* last vote slot for this validator */
341+
340342
fd_gui_peers_vote_t votes [ FD_RUNTIME_MAX_VOTE_ACCOUNTS ];
341343
fd_gui_peers_vote_t votes_scratch[ FD_RUNTIME_MAX_VOTE_ACCOUNTS ]; /* for fast stable sort */
342344
};
@@ -395,6 +397,7 @@ fd_gui_peers_handle_vote_update( fd_gui_peers_ctx_t * peers,
395397
fd_gui_peers_vote_t * votes,
396398
ulong vote_cnt,
397399
long now,
400+
fd_pubkey_t * identity,
398401
char country_code_map[ static 512 ][ 3 ] );
399402

400403
void

src/disco/gui/fd_gui_printf.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,14 @@ fd_gui_printf_repair_slot( fd_gui_t * gui ) {
242242
jsonp_close_envelope( gui->http );
243243
}
244244

245+
void
246+
fd_gui_peers_printf_vote_slot( fd_gui_peers_ctx_t * peers ) {
247+
jsonp_open_envelope( peers->http, "summary", "vote_slot" );
248+
if( FD_LIKELY( peers->slot_voted!=ULONG_MAX ) ) jsonp_ulong( peers->http, "value", peers->slot_voted );
249+
else jsonp_null ( peers->http, "value" );
250+
jsonp_close_envelope( peers->http );
251+
}
252+
245253
void
246254
fd_gui_printf_turbine_slot( fd_gui_t * gui ) {
247255
jsonp_open_envelope( gui->http, "summary", "turbine_slot" );

src/disco/gui/fd_gui_printf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void fd_gui_printf_estimated_slot( fd_gui_t * gui );
3636
void fd_gui_printf_estimated_tps( fd_gui_t * gui );
3737
void fd_gui_printf_shred_updates( fd_gui_t * gui );
3838
void fd_gui_printf_catch_up_history( fd_gui_t * gui );
39+
void fd_gui_peers_printf_vote_slot( fd_gui_peers_ctx_t * peers );
3940

4041
void
4142
fd_gui_printf_null_query_response( fd_http_server_t * http,

src/disco/gui/fd_gui_tile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ after_frag( fd_gui_ctx_t * ctx,
363363
fd_stem_publish( stem, ctx->replay_out->idx, replay->bank_idx, 0UL, 0UL, 0UL, 0UL, 0UL );
364364

365365
/* update vote info */
366-
fd_gui_peers_handle_vote_update( ctx->peers, ctx->peers->votes, vote_count, fd_clock_now( ctx->clock ), ctx->gui->ipinfo.country_code );
366+
fd_gui_peers_handle_vote_update( ctx->peers, ctx->peers->votes, vote_count, fd_clock_now( ctx->clock ), ctx->gui->summary.identity_key, ctx->gui->ipinfo.country_code );
367367

368368
/* update slot data */
369369
fd_gui_handle_replay_update( ctx->gui, &slot_completed, fd_clock_now( ctx->clock ) );

0 commit comments

Comments
 (0)