Skip to content

Commit 498cb60

Browse files
committed
gui: vote slot message
1 parent a38b0a0 commit 498cb60

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
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.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ fd_gui_ws_open( fd_gui_t * gui,
300300
fd_gui_printf_optimistically_confirmed_slot,
301301
fd_gui_printf_completed_slot,
302302
fd_gui_printf_estimated_slot,
303+
fd_gui_printf_vote_slot,
303304
fd_gui_printf_live_tile_timers,
304305
fd_gui_printf_catch_up_history,
305306
};
@@ -1834,6 +1835,12 @@ fd_gui_handle_reset_slot_legacy( fd_gui_t * gui,
18341835
}
18351836
}
18361837

1838+
if( FD_LIKELY( last_landed_vote!=ULONG_MAX && gui->summary.slot_voted!=last_landed_vote ) ) {
1839+
gui->summary.slot_voted = last_landed_vote;
1840+
fd_gui_printf_vote_slot( gui );
1841+
fd_http_server_ws_broadcast( gui->http );
1842+
}
1843+
18371844
if( FD_UNLIKELY( gui->summary.vote_distance!=_slot-last_landed_vote ) ) {
18381845
gui->summary.vote_distance = _slot-last_landed_vote;
18391846
fd_gui_printf_vote_distance( gui );
@@ -2540,6 +2547,12 @@ fd_gui_handle_tower_update( fd_gui_t * gui,
25402547
long now ) {
25412548
(void)now;
25422549

2550+
if( FD_LIKELY( tower->vote_slot!=ULONG_MAX && gui->summary.slot_voted!=tower->vote_slot ) ) {
2551+
gui->summary.slot_voted = tower->vote_slot;
2552+
fd_gui_printf_vote_slot( gui );
2553+
fd_http_server_ws_broadcast( gui->http );
2554+
}
2555+
25432556
/* handle new root */
25442557
if( FD_LIKELY( tower->root_slot!=ULONG_MAX && gui->summary.slot_rooted!=tower->root_slot ) ) {
25452558
fd_gui_handle_rooted_slot( gui, tower->root_slot );

src/disco/gui/fd_gui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ struct fd_gui {
611611
ulong bank_tile_cnt;
612612
ulong shred_tile_cnt;
613613

614+
ulong slot_voted;
614615
ulong slot_rooted;
615616
ulong slot_optimistically_confirmed;
616617
ulong slot_completed;

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_printf_vote_slot( fd_gui_t * gui ) {
247+
jsonp_open_envelope( gui->http, "summary", "vote_slot" );
248+
if( FD_LIKELY( gui->summary.slot_voted!=ULONG_MAX ) ) jsonp_ulong( gui->http, "value", gui->summary.slot_voted );
249+
else jsonp_null ( gui->http, "value" );
250+
jsonp_close_envelope( gui->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
@@ -17,6 +17,7 @@ void fd_gui_printf_vote_state( fd_gui_t * gui );
1717
void fd_gui_printf_vote_distance( fd_gui_t * gui );
1818
void fd_gui_printf_turbine_slot( fd_gui_t * gui );
1919
void fd_gui_printf_repair_slot( fd_gui_t * gui );
20+
void fd_gui_printf_vote_slot( fd_gui_t * gui );
2021
void fd_gui_printf_slot_caught_up( fd_gui_t * gui );
2122
void fd_gui_printf_skipped_history( fd_gui_t * gui );
2223
void fd_gui_printf_skipped_history_cluster( fd_gui_t * gui );

0 commit comments

Comments
 (0)