Line data Source code
1 : #include "fd_gui_printf.h"
2 : #include "fd_gui_config_parse.h"
3 :
4 : #include "../../waltz/http/fd_http_server_private.h"
5 : #include "../../ballet/utf8/fd_utf8.h"
6 : #include "../../disco/fd_txn_m.h"
7 : #include "../../disco/metrics/fd_metrics.h"
8 :
9 : #ifdef __has_include
10 : #if __has_include("../../app/fdctl/version.h")
11 : #include "../../app/fdctl/version.h"
12 : #endif
13 : #endif
14 :
15 : #ifndef FDCTL_COMMIT_REF_CSTR
16 : #define FDCTL_COMMIT_REF_CSTR "0000000000000000000000000000000000000000"
17 : #endif
18 :
19 : static void
20 0 : jsonp_strip_trailing_comma( fd_http_server_t * http ) {
21 0 : if( FD_LIKELY( !http->stage_err &&
22 0 : http->stage_len>=1UL &&
23 0 : http->oring[ (http->stage_off%http->oring_sz)+http->stage_len-1UL ]==(uchar)',' ) ) {
24 0 : http->stage_len--;
25 0 : }
26 0 : }
27 :
28 : static void
29 : jsonp_open_object( fd_http_server_t * http,
30 0 : char const * key ) {
31 0 : if( FD_LIKELY( key ) ) fd_http_server_printf( http, "\"%s\":{", key );
32 0 : else fd_http_server_printf( http, "{" );
33 0 : }
34 :
35 : static void
36 0 : jsonp_close_object( fd_http_server_t * http ) {
37 0 : jsonp_strip_trailing_comma( http );
38 0 : fd_http_server_printf( http, "}," );
39 0 : }
40 :
41 : static void
42 : jsonp_open_array( fd_http_server_t * http,
43 0 : char const * key ) {
44 0 : if( FD_LIKELY( key ) ) fd_http_server_printf( http, "\"%s\":[", key );
45 0 : else fd_http_server_printf( http, "[" );
46 0 : }
47 :
48 : static void
49 0 : jsonp_close_array( fd_http_server_t * http ) {
50 0 : jsonp_strip_trailing_comma( http );
51 0 : fd_http_server_printf( http, "]," );
52 0 : }
53 :
54 : static void
55 : jsonp_ulong( fd_http_server_t * http,
56 : char const * key,
57 0 : ulong value ) {
58 0 : if( FD_LIKELY( key ) ) fd_http_server_printf( http, "\"%s\":%lu,", key, value );
59 0 : else fd_http_server_printf( http, "%lu,", value );
60 0 : }
61 :
62 : static void
63 : jsonp_long( fd_http_server_t * http,
64 : char const * key,
65 0 : long value ) {
66 0 : if( FD_LIKELY( key ) ) fd_http_server_printf( http, "\"%s\":%ld,", key, value );
67 0 : else fd_http_server_printf( http, "%ld,", value );
68 0 : }
69 :
70 : static void
71 : jsonp_double( fd_http_server_t * http,
72 : char const * key,
73 0 : double value ) {
74 0 : if( FD_LIKELY( key ) ) fd_http_server_printf( http, "\"%s\":%.2f,", key, value );
75 0 : else fd_http_server_printf( http, "%.2f,", value );
76 0 : }
77 :
78 : static void
79 : jsonp_ulong_as_str( fd_http_server_t * http,
80 : char const * key,
81 0 : ulong value ) {
82 0 : if( FD_LIKELY( key ) ) fd_http_server_printf( http, "\"%s\":\"%lu\",", key, value );
83 0 : else fd_http_server_printf( http, "\"%lu\",", value );
84 0 : }
85 :
86 : static void
87 : jsonp_long_as_str( fd_http_server_t * http,
88 : char const * key,
89 0 : long value ) {
90 0 : if( FD_LIKELY( key ) ) fd_http_server_printf( http, "\"%s\":\"%ld\",", key, value );
91 0 : else fd_http_server_printf( http, "\"%ld\",", value );
92 0 : }
93 :
94 : static void
95 : jsonp_sanitize_str( fd_http_server_t * http,
96 0 : ulong start_len ) {
97 : /* escape quotemark, reverse solidus, and control chars U+0000 through U+001F
98 : just replace with a space */
99 0 : uchar * data = http->oring;
100 0 : for( ulong i=start_len; i<http->stage_len; i++ ) {
101 0 : if( FD_UNLIKELY( data[ (http->stage_off%http->oring_sz)+i ] < 0x20 ||
102 0 : data[ (http->stage_off%http->oring_sz)+i ] == '"' ||
103 0 : data[ (http->stage_off%http->oring_sz)+i ] == '\\' ) ) {
104 0 : data[ (http->stage_off%http->oring_sz)+i ] = ' ';
105 0 : }
106 0 : }
107 0 : }
108 :
109 : static void
110 : jsonp_string( fd_http_server_t * http,
111 : char const * key,
112 0 : char const * value ) {
113 0 : char * val = (void *)value;
114 0 : if( FD_LIKELY( value ) ) {
115 0 : if( FD_UNLIKELY( !fd_utf8_verify( value, strlen( value ) ) )) {
116 0 : val = NULL;
117 0 : }
118 0 : }
119 0 : if( FD_LIKELY( key ) ) fd_http_server_printf( http, "\"%s\":", key );
120 0 : if( FD_LIKELY( val ) ) {
121 0 : fd_http_server_printf( http, "\"" );
122 0 : ulong start_len = http->stage_len;
123 0 : fd_http_server_printf( http, "%s", val );
124 0 : jsonp_sanitize_str( http, start_len );
125 0 : fd_http_server_printf( http, "\"," );
126 0 : } else {
127 0 : fd_http_server_printf( http, "null," );
128 0 : }
129 0 : }
130 :
131 : static void
132 : jsonp_bool( fd_http_server_t * http,
133 : char const * key,
134 0 : int value ) {
135 0 : if( FD_LIKELY( key ) ) fd_http_server_printf( http, "\"%s\":%s,", key, value ? "true" : "false" );
136 0 : else fd_http_server_printf( http, "%s,", value ? "true" : "false" );
137 0 : }
138 :
139 : static void
140 : jsonp_null( fd_http_server_t * http,
141 0 : char const * key ) {
142 0 : if( FD_LIKELY( key ) ) fd_http_server_printf( http, "\"%s\": null,", key );
143 0 : else fd_http_server_printf( http, "null," );
144 0 : }
145 :
146 : static void
147 : jsonp_open_envelope( fd_http_server_t * http,
148 : char const * topic,
149 0 : char const * key ) {
150 0 : jsonp_open_object( http, NULL );
151 0 : jsonp_string( http, "topic", topic );
152 0 : jsonp_string( http, "key", key );
153 0 : }
154 :
155 : static void
156 0 : jsonp_close_envelope( fd_http_server_t * http ) {
157 0 : jsonp_close_object( http );
158 0 : jsonp_strip_trailing_comma( http );
159 0 : }
160 :
161 : void
162 : fd_gui_printf_open_query_response_envelope( fd_http_server_t * http,
163 : char const * topic,
164 : char const * key,
165 0 : ulong id ) {
166 0 : jsonp_open_object( http, NULL );
167 0 : jsonp_string( http, "topic", topic );
168 0 : jsonp_string( http, "key", key );
169 0 : jsonp_ulong( http, "id", id );
170 0 : }
171 :
172 : void
173 0 : fd_gui_printf_close_query_response_envelope( fd_http_server_t * http ) {
174 0 : jsonp_close_object( http );
175 0 : jsonp_strip_trailing_comma( http );
176 0 : }
177 :
178 : void
179 : fd_gui_printf_null_query_response( fd_http_server_t * http,
180 : char const * topic,
181 : char const * key,
182 0 : ulong id ) {
183 0 : fd_gui_printf_open_query_response_envelope( http, topic, key, id );
184 0 : jsonp_null( http, "value" );
185 0 : fd_gui_printf_close_query_response_envelope( http );
186 0 : }
187 :
188 : void
189 0 : fd_gui_printf_version( fd_gui_t * gui ) {
190 0 : jsonp_open_envelope( gui->http, "summary", "version" );
191 0 : jsonp_string( gui->http, "value", gui->summary.version );
192 0 : jsonp_close_envelope( gui->http );
193 0 : }
194 :
195 : void
196 0 : fd_gui_printf_cluster( fd_gui_t * gui ) {
197 0 : jsonp_open_envelope( gui->http, "summary", "cluster" );
198 0 : jsonp_string( gui->http, "value", gui->summary.cluster );
199 0 : jsonp_close_envelope( gui->http );
200 0 : }
201 :
202 : void
203 0 : fd_gui_printf_commit_hash( fd_gui_t * gui ) {
204 0 : jsonp_open_envelope( gui->http, "summary", "commit_hash" );
205 0 : jsonp_string( gui->http, "value", FDCTL_COMMIT_REF_CSTR );
206 0 : jsonp_close_envelope( gui->http );
207 0 : }
208 :
209 : void
210 0 : fd_gui_printf_identity_key( fd_gui_t * gui ) {
211 0 : jsonp_open_envelope( gui->http, "summary", "identity_key" );
212 0 : jsonp_string( gui->http, "value", gui->summary.identity_key_base58 );
213 0 : jsonp_close_envelope( gui->http );
214 0 : }
215 :
216 : void
217 0 : fd_gui_printf_vote_key( fd_gui_t * gui ) {
218 0 : jsonp_open_envelope( gui->http, "summary", "vote_key" );
219 0 : if( FD_LIKELY( gui->summary.has_vote_key ) ) jsonp_string( gui->http, "value", gui->summary.vote_key_base58 );
220 0 : else jsonp_null( gui->http, "value" );
221 0 : jsonp_close_envelope( gui->http );
222 0 : }
223 :
224 : void
225 0 : fd_gui_printf_startup_time_nanos( fd_gui_t * gui ) {
226 0 : jsonp_open_envelope( gui->http, "summary", "startup_time_nanos" );
227 0 : jsonp_long_as_str( gui->http, "value", gui->summary.startup_time_nanos );
228 0 : jsonp_close_envelope( gui->http );
229 0 : }
230 :
231 : void
232 0 : fd_gui_printf_server_time_nanos( fd_gui_t * gui, long now ) {
233 0 : jsonp_open_envelope( gui->http, "summary", "server_time_nanos" );
234 0 : jsonp_long_as_str( gui->http, "value", now );
235 0 : jsonp_close_envelope( gui->http );
236 0 : }
237 :
238 : void
239 0 : fd_gui_printf_vote_distance( fd_gui_t * gui ) {
240 0 : jsonp_open_envelope( gui->http, "summary", "vote_distance" );
241 0 : jsonp_ulong( gui->http, "value", gui->summary.vote_distance );
242 0 : jsonp_close_envelope( gui->http );
243 0 : }
244 :
245 : void
246 0 : fd_gui_printf_repair_slot( fd_gui_t * gui ) {
247 0 : jsonp_open_envelope( gui->http, "summary", "repair_slot" );
248 0 : if( FD_LIKELY( gui->summary.slot_repair!=ULONG_MAX ) ) jsonp_ulong( gui->http, "value", gui->summary.slot_repair );
249 0 : else jsonp_null ( gui->http, "value" );
250 0 : jsonp_close_envelope( gui->http );
251 0 : }
252 :
253 : void
254 0 : fd_gui_peers_printf_vote_slot( fd_gui_peers_ctx_t * peers ) {
255 0 : jsonp_open_envelope( peers->http, "summary", "vote_slot" );
256 0 : if( FD_LIKELY( peers->slot_voted!=ULONG_MAX ) ) jsonp_ulong( peers->http, "value", peers->slot_voted );
257 0 : else jsonp_null ( peers->http, "value" );
258 0 : jsonp_close_envelope( peers->http );
259 0 : }
260 :
261 : void
262 0 : fd_gui_printf_turbine_slot( fd_gui_t * gui ) {
263 0 : jsonp_open_envelope( gui->http, "summary", "turbine_slot" );
264 0 : if( FD_LIKELY( gui->summary.slot_turbine!=ULONG_MAX ) ) jsonp_ulong( gui->http, "value", gui->summary.slot_turbine );
265 0 : else jsonp_null ( gui->http, "value" );
266 0 : jsonp_close_envelope( gui->http );
267 0 : }
268 :
269 : void
270 0 : fd_gui_printf_reset_slot( fd_gui_t * gui ) {
271 0 : jsonp_open_envelope( gui->http, "summary", "reset_slot" );
272 0 : if( FD_LIKELY( gui->summary.slot_reset!=ULONG_MAX ) ) jsonp_ulong( gui->http, "value", gui->summary.slot_reset );
273 0 : else jsonp_null ( gui->http, "value" );
274 0 : jsonp_close_envelope( gui->http );
275 0 : }
276 :
277 : void
278 0 : fd_gui_printf_storage_slot( fd_gui_t * gui ) {
279 0 : jsonp_open_envelope( gui->http, "summary", "storage_slot" );
280 0 : if( FD_LIKELY( gui->summary.slot_storage!=ULONG_MAX ) ) jsonp_ulong( gui->http, "value", gui->summary.slot_storage );
281 0 : else jsonp_null ( gui->http, "value" );
282 0 : jsonp_close_envelope( gui->http );
283 0 : }
284 :
285 : void
286 0 : fd_gui_printf_active_fork_cnt( fd_gui_t * gui ) {
287 0 : jsonp_open_envelope( gui->http, "summary", "active_fork_count" );
288 0 : if( FD_LIKELY( gui->summary.active_fork_cnt!=ULONG_MAX ) ) jsonp_ulong( gui->http, "value", gui->summary.active_fork_cnt );
289 0 : else jsonp_null ( gui->http, "value" );
290 0 : jsonp_close_envelope( gui->http );
291 0 : }
292 :
293 : void
294 0 : fd_gui_printf_slot_caught_up( fd_gui_t * gui ) {
295 0 : jsonp_open_envelope( gui->http, "summary", "slot_caught_up" );
296 0 : if( FD_LIKELY( gui->summary.slot_caught_up!=ULONG_MAX ) ) jsonp_ulong( gui->http, "value", gui->summary.slot_caught_up );
297 0 : else jsonp_null ( gui->http, "value" );
298 0 : jsonp_close_envelope( gui->http );
299 0 : }
300 :
301 : void
302 0 : fd_gui_printf_catch_up_history( fd_gui_t * gui ) {
303 0 : jsonp_open_envelope( gui->http, "summary", "catch_up_history" );
304 0 : jsonp_open_object( gui->http, "value" );
305 0 : jsonp_open_array( gui->http, "turbine" );
306 0 : for( ulong i=0UL; i<gui->summary.catch_up_turbine_sz; i+=2 ) {
307 0 : for( ulong j=gui->summary.catch_up_turbine[ i ]; j<=gui->summary.catch_up_turbine[ i+1UL ]; j++ ) {
308 0 : jsonp_ulong( gui->http, NULL, j );
309 0 : }
310 0 : }
311 0 : jsonp_close_array( gui->http );
312 0 : jsonp_open_array( gui->http, "repair" );
313 0 : for( ulong i=0UL; i<gui->summary.catch_up_repair_sz; i+=2 ) {
314 0 : for( ulong j=gui->summary.catch_up_repair[ i ]; j<=gui->summary.catch_up_repair[ i+1UL ]; j++ ) {
315 0 : jsonp_ulong( gui->http, NULL, j );
316 0 : }
317 0 : }
318 0 : jsonp_close_array( gui->http );
319 :
320 0 : if( FD_LIKELY( gui->summary.boot_progress.phase==FD_GUI_BOOT_PROGRESS_TYPE_CATCHING_UP ) ) {
321 0 : ulong min_slot = ULONG_MAX;
322 0 : long min_ts = LONG_MAX;
323 :
324 0 : #define SHREDS_REV_ITER( age_ns, code_staged, code_archive ) \
325 0 : do { \
326 0 : if( FD_UNLIKELY( gui->summary.boot_progress.catching_up_time_nanos==0L ) ) break; \
327 0 : for( ulong i=gui->shreds.staged_tail; i>gui->shreds.staged_head; i-- ) { \
328 0 : fd_gui_slot_staged_shred_event_t * event = &gui->shreds.staged[ (i-1UL) % FD_GUI_SHREDS_STAGING_SZ ]; \
329 0 : if( FD_UNLIKELY( event->timestamp < gui->summary.boot_progress.catching_up_time_nanos - age_ns ) ) break; \
330 0 : do { code_staged } while(0); \
331 0 : } \
332 0 : fd_gui_slot_t * s = fd_gui_get_slot( gui, gui->shreds.history_slot ); \
333 0 : while( s \
334 0 : && s->shreds.start_offset!=ULONG_MAX \
335 0 : && s->shreds.end_offset!=ULONG_MAX \
336 0 : && s->shreds.end_offset>s->shreds.start_offset \
337 0 : && gui->shreds.history[ (s->shreds.end_offset-1UL) % FD_GUI_SHREDS_HISTORY_SZ ].timestamp + age_ns > gui->summary.boot_progress.catching_up_time_nanos ) { \
338 0 : for( ulong i=s->shreds.end_offset; i>s->shreds.start_offset; i-- ) { \
339 0 : fd_gui_slot_history_shred_event_t * event = &gui->shreds.history[ (i-1UL) % FD_GUI_SHREDS_HISTORY_SZ ]; (void)event; \
340 0 : do { code_archive } while (0); \
341 0 : } \
342 0 : s = fd_gui_get_slot( gui, s->parent_slot ); \
343 0 : } \
344 0 : } while(0);
345 :
346 0 : SHREDS_REV_ITER(
347 0 : 15000000000,
348 0 : {
349 0 : min_slot = fd_ulong_min( min_slot, event->slot );
350 0 : min_ts = fd_long_min( min_ts, event->timestamp );
351 0 : },
352 0 : {
353 0 : min_slot = fd_ulong_min( min_slot, s->slot );
354 0 : min_ts = fd_long_min( min_ts, event->timestamp );
355 0 : }
356 0 : )
357 :
358 0 : jsonp_open_object( gui->http, "shreds" );
359 0 : jsonp_ulong ( gui->http, "reference_slot", min_slot );
360 0 : jsonp_long_as_str( gui->http, "reference_ts", min_ts );
361 :
362 0 : jsonp_open_array( gui->http, "slot_delta" );
363 0 : SHREDS_REV_ITER(
364 0 : 15000000000L,
365 0 : { jsonp_ulong( gui->http, NULL, event->slot-min_slot ); },
366 0 : { jsonp_ulong( gui->http, NULL, s->slot-min_slot ); }
367 0 : )
368 0 : jsonp_close_array( gui->http );
369 0 : jsonp_open_array( gui->http, "shred_idx" );
370 0 : SHREDS_REV_ITER(
371 0 : 15000000000L,
372 0 : {
373 0 : if( FD_LIKELY( event->shred_idx!=USHORT_MAX ) ) jsonp_ulong( gui->http, NULL, event->shred_idx );
374 0 : else jsonp_null ( gui->http, NULL );
375 0 : },
376 0 : {
377 0 : if( FD_LIKELY( event->shred_idx!=USHORT_MAX ) ) jsonp_ulong( gui->http, NULL, event->shred_idx );
378 0 : else jsonp_null ( gui->http, NULL );
379 0 : }
380 0 : )
381 0 : jsonp_close_array( gui->http );
382 0 : jsonp_open_array( gui->http, "event" );
383 0 : SHREDS_REV_ITER(
384 0 : 15000000000L,
385 0 : { jsonp_ulong( gui->http, NULL, event->event ); },
386 0 : { jsonp_ulong( gui->http, NULL, event->event ); }
387 0 : )
388 0 : jsonp_close_array( gui->http );
389 0 : jsonp_open_array( gui->http, "event_ts_delta" );
390 0 : SHREDS_REV_ITER(
391 0 : 15000000000L,
392 0 : { jsonp_long_as_str( gui->http, NULL, event->timestamp-min_ts ); },
393 0 : { jsonp_long_as_str( gui->http, NULL, event->timestamp-min_ts ); }
394 0 : )
395 0 : jsonp_close_array( gui->http );
396 0 : jsonp_close_object( gui->http );
397 0 : } else {
398 0 : jsonp_null( gui->http, "shreds" );
399 0 : }
400 :
401 0 : jsonp_close_object( gui->http );
402 0 : jsonp_close_envelope( gui->http );
403 0 : }
404 :
405 : void
406 0 : fd_gui_printf_vote_state( fd_gui_t * gui ) {
407 0 : jsonp_open_envelope( gui->http, "summary", "vote_state" );
408 0 : switch( gui->summary.vote_state ) {
409 0 : case FD_GUI_VOTE_STATE_NON_VOTING:
410 0 : jsonp_string( gui->http, "value", "non-voting" );
411 0 : break;
412 0 : case FD_GUI_VOTE_STATE_VOTING:
413 0 : jsonp_string( gui->http, "value", "voting" );
414 0 : break;
415 0 : case FD_GUI_VOTE_STATE_DELINQUENT:
416 0 : jsonp_string( gui->http, "value", "delinquent" );
417 0 : break;
418 0 : default:
419 0 : FD_LOG_ERR(( "unknown vote state %d", gui->summary.vote_state ));
420 0 : }
421 0 : jsonp_close_envelope( gui->http );
422 0 : }
423 :
424 : void
425 0 : fd_gui_printf_skipped_history( fd_gui_t * gui, ulong epoch_idx ) {
426 0 : jsonp_open_envelope( gui->http, "slot", "skipped_history" );
427 0 : jsonp_open_array( gui->http, "value" );
428 0 : ulong start_slot = gui->epoch.epochs[ epoch_idx ].start_slot;
429 0 : ulong end_slot = gui->epoch.epochs[ epoch_idx ].end_slot;
430 0 : for( ulong s=start_slot; s<fd_ulong_min( end_slot, start_slot+FD_GUI_SLOTS_CNT ); s++ ) {
431 0 : if( FD_LIKELY( gui->summary.slot_completed==ULONG_MAX ) ) break;
432 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, s );
433 :
434 0 : if( FD_UNLIKELY( !slot ) ) continue;
435 0 : if( FD_UNLIKELY( slot->mine && slot->skipped ) ) jsonp_ulong( gui->http, NULL, slot->slot );
436 0 : }
437 0 : jsonp_close_array( gui->http );
438 0 : jsonp_close_envelope( gui->http );
439 0 : }
440 :
441 : void
442 0 : fd_gui_printf_skipped_history_cluster( fd_gui_t * gui, ulong epoch_idx ) {
443 0 : jsonp_open_envelope( gui->http, "slot", "skipped_history_cluster" );
444 0 : jsonp_open_array( gui->http, "value" );
445 0 : ulong start_slot = gui->epoch.epochs[ epoch_idx ].start_slot;
446 0 : ulong end_slot = gui->epoch.epochs[ epoch_idx ].end_slot;
447 0 : for( ulong s=start_slot; s<fd_ulong_min( end_slot, start_slot+FD_GUI_SLOTS_CNT ); s++ ) {
448 0 : if( FD_LIKELY( gui->summary.slot_completed==ULONG_MAX ) ) break;
449 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, s );
450 :
451 0 : if( FD_UNLIKELY( !slot ) ) continue;
452 0 : if( FD_UNLIKELY( slot->skipped ) ) jsonp_ulong( gui->http, NULL, slot->slot );
453 0 : }
454 0 : jsonp_close_array( gui->http );
455 0 : jsonp_close_envelope( gui->http );
456 0 : }
457 :
458 : /* TODO: deprecated */
459 : void
460 0 : fd_gui_printf_vote_latency_history( fd_gui_t * gui ) {
461 0 : jsonp_open_envelope( gui->http, "slot", "vote_latency_history" );
462 0 : jsonp_open_array( gui->http, "value" );
463 0 : FD_TEST( gui->summary.late_votes_sz % 2UL == 0UL );
464 0 : for( ulong i=0UL; i<gui->summary.late_votes_sz; i++ ) jsonp_ulong( gui->http, NULL, gui->summary.late_votes[ i ] );
465 0 : jsonp_close_array( gui->http );
466 0 : jsonp_close_envelope( gui->http );
467 0 : }
468 :
469 : void
470 0 : fd_gui_printf_late_votes_history( fd_gui_t * gui ) {
471 0 : jsonp_open_envelope( gui->http, "slot", "late_votes_history" );
472 0 : jsonp_open_object( gui->http, "value" );
473 0 : jsonp_open_array( gui->http, "slot" );
474 0 : for( ulong i=0UL; i<gui->summary.late_votes_sz; i++ ) jsonp_ulong( gui->http, NULL, gui->summary.late_votes[ i ] );
475 0 : jsonp_close_array( gui->http );
476 0 : jsonp_open_array( gui->http, "latency" );
477 0 : for( long i=0UL; i<(long)gui->summary.late_votes_sz-1L; i+=2L ) {
478 0 : FD_TEST( (ulong)i+1<gui->summary.late_votes_sz );
479 0 : ulong s = gui->summary.late_votes[ i ];
480 0 : ulong s2 = gui->summary.late_votes[ i + 1 ];
481 0 : for( ulong j=s; j<=fd_ulong_min( s2, s+FD_GUI_SLOTS_CNT ); j++ ) {
482 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, j );
483 0 : if( FD_UNLIKELY( slot && slot->vote_latency!=UCHAR_MAX ) ) jsonp_ulong( gui->http, NULL, slot->vote_latency );
484 0 : else jsonp_null( gui->http, NULL );
485 0 : }
486 0 : }
487 0 : jsonp_close_array( gui->http );
488 0 : jsonp_close_object( gui->http );
489 0 : jsonp_close_envelope( gui->http );
490 0 : }
491 :
492 : void
493 0 : fd_gui_printf_tps_history( fd_gui_t * gui ) {
494 0 : jsonp_open_envelope( gui->http, "summary", "tps_history" );
495 0 : jsonp_open_array( gui->http, "value" );
496 :
497 0 : for( ulong i=0UL; i<FD_GUI_TPS_HISTORY_SAMPLE_CNT; i++ ) {
498 0 : ulong idx = (gui->summary.estimated_tps_history_idx+i) % FD_GUI_TPS_HISTORY_SAMPLE_CNT;
499 0 : ulong vote_cnt = gui->summary.estimated_tps_history[ idx ].vote_failed
500 0 : + gui->summary.estimated_tps_history[ idx ].vote_success;
501 0 : ulong total_cnt = vote_cnt
502 0 : + gui->summary.estimated_tps_history[ idx ].nonvote_success
503 0 : + gui->summary.estimated_tps_history[ idx ].nonvote_failed;
504 0 : jsonp_open_array( gui->http, NULL );
505 0 : jsonp_double( gui->http, NULL, (double)total_cnt/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
506 0 : jsonp_double( gui->http, NULL, (double)vote_cnt/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
507 0 : jsonp_double( gui->http, NULL, (double)gui->summary.estimated_tps_history[ idx ].nonvote_success/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
508 0 : jsonp_double( gui->http, NULL, (double)gui->summary.estimated_tps_history[ idx ].nonvote_failed/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
509 0 : jsonp_close_array( gui->http );
510 0 : }
511 :
512 0 : jsonp_close_array( gui->http );
513 0 : jsonp_close_envelope( gui->http );
514 0 : }
515 :
516 : void
517 0 : fd_gui_printf_startup_progress( fd_gui_t * gui ) {
518 0 : char const * phase;
519 :
520 0 : switch( gui->summary.startup_progress.phase ) {
521 0 : case FD_GUI_START_PROGRESS_TYPE_INITIALIZING:
522 0 : phase = "initializing";
523 0 : break;
524 0 : case FD_GUI_START_PROGRESS_TYPE_SEARCHING_FOR_FULL_SNAPSHOT:
525 0 : phase = "searching_for_full_snapshot";
526 0 : break;
527 0 : case FD_GUI_START_PROGRESS_TYPE_DOWNLOADING_FULL_SNAPSHOT:
528 0 : phase = "downloading_full_snapshot";
529 0 : break;
530 0 : case FD_GUI_START_PROGRESS_TYPE_SEARCHING_FOR_INCREMENTAL_SNAPSHOT:
531 0 : phase = "searching_for_incremental_snapshot";
532 0 : break;
533 0 : case FD_GUI_START_PROGRESS_TYPE_DOWNLOADING_INCREMENTAL_SNAPSHOT:
534 0 : phase = "downloading_incremental_snapshot";
535 0 : break;
536 0 : case FD_GUI_START_PROGRESS_TYPE_CLEANING_BLOCK_STORE:
537 0 : phase = "cleaning_blockstore";
538 0 : break;
539 0 : case FD_GUI_START_PROGRESS_TYPE_CLEANING_ACCOUNTS:
540 0 : phase = "cleaning_accounts";
541 0 : break;
542 0 : case FD_GUI_START_PROGRESS_TYPE_LOADING_LEDGER:
543 0 : phase = "loading_ledger";
544 0 : break;
545 0 : case FD_GUI_START_PROGRESS_TYPE_PROCESSING_LEDGER:
546 0 : phase = "processing_ledger";
547 0 : break;
548 0 : case FD_GUI_START_PROGRESS_TYPE_STARTING_SERVICES:
549 0 : phase = "starting_services";
550 0 : break;
551 0 : case FD_GUI_START_PROGRESS_TYPE_HALTED:
552 0 : phase = "halted";
553 0 : break;
554 0 : case FD_GUI_START_PROGRESS_TYPE_WAITING_FOR_SUPERMAJORITY:
555 0 : phase = "waiting_for_supermajority";
556 0 : break;
557 0 : case FD_GUI_START_PROGRESS_TYPE_RUNNING:
558 0 : phase = "running";
559 0 : break;
560 0 : default:
561 0 : FD_LOG_ERR(( "unknown phase %d", gui->summary.startup_progress.phase ));
562 0 : }
563 :
564 0 : jsonp_open_envelope( gui->http, "summary", "startup_progress" );
565 0 : jsonp_open_object( gui->http, "value" );
566 0 : jsonp_string( gui->http, "phase", phase );
567 0 : if( FD_LIKELY( gui->summary.startup_progress.phase>=FD_GUI_START_PROGRESS_TYPE_DOWNLOADING_FULL_SNAPSHOT) ) {
568 0 : char peer_addr[ 64 ];
569 0 : FD_TEST( fd_cstr_printf_check( peer_addr, sizeof(peer_addr), NULL, FD_IP4_ADDR_FMT ":%u", FD_IP4_ADDR_FMT_ARGS(gui->summary.startup_progress.startup_full_snapshot_peer_ip_addr), gui->summary.startup_progress.startup_full_snapshot_peer_port ) );
570 :
571 0 : jsonp_string( gui->http, "downloading_full_snapshot_peer", peer_addr );
572 0 : jsonp_ulong( gui->http, "downloading_full_snapshot_slot", gui->summary.startup_progress.startup_full_snapshot_slot );
573 0 : jsonp_double( gui->http, "downloading_full_snapshot_elapsed_secs", gui->summary.startup_progress.startup_full_snapshot_elapsed_secs );
574 0 : jsonp_double( gui->http, "downloading_full_snapshot_remaining_secs", gui->summary.startup_progress.startup_full_snapshot_remaining_secs );
575 0 : jsonp_double( gui->http, "downloading_full_snapshot_throughput", gui->summary.startup_progress.startup_full_snapshot_throughput );
576 0 : jsonp_ulong( gui->http, "downloading_full_snapshot_total_bytes", gui->summary.startup_progress.startup_full_snapshot_total_bytes );
577 0 : jsonp_ulong( gui->http, "downloading_full_snapshot_current_bytes", gui->summary.startup_progress.startup_full_snapshot_current_bytes );
578 0 : } else {
579 0 : jsonp_null( gui->http, "downloading_full_snapshot_peer" );
580 0 : jsonp_null( gui->http, "downloading_full_snapshot_slot" );
581 0 : jsonp_null( gui->http, "downloading_full_snapshot_elapsed_secs" );
582 0 : jsonp_null( gui->http, "downloading_full_snapshot_remaining_secs" );
583 0 : jsonp_null( gui->http, "downloading_full_snapshot_throughput" );
584 0 : jsonp_null( gui->http, "downloading_full_snapshot_total_bytes" );
585 0 : jsonp_null( gui->http, "downloading_full_snapshot_current_bytes" );
586 0 : }
587 :
588 0 : if( FD_LIKELY( gui->summary.startup_progress.phase>=FD_GUI_START_PROGRESS_TYPE_DOWNLOADING_INCREMENTAL_SNAPSHOT) ) {
589 0 : char peer_addr[ 64 ];
590 0 : FD_TEST( fd_cstr_printf_check( peer_addr, sizeof(peer_addr), NULL, FD_IP4_ADDR_FMT ":%u", FD_IP4_ADDR_FMT_ARGS(gui->summary.startup_progress.startup_incremental_snapshot_peer_ip_addr), gui->summary.startup_progress.startup_incremental_snapshot_peer_port ) );
591 :
592 0 : jsonp_string( gui->http, "downloading_incremental_snapshot_peer", peer_addr );
593 0 : jsonp_ulong( gui->http, "downloading_incremental_snapshot_slot", gui->summary.startup_progress.startup_incremental_snapshot_slot );
594 0 : jsonp_double( gui->http, "downloading_incremental_snapshot_elapsed_secs", gui->summary.startup_progress.startup_incremental_snapshot_elapsed_secs );
595 0 : jsonp_double( gui->http, "downloading_incremental_snapshot_remaining_secs", gui->summary.startup_progress.startup_incremental_snapshot_remaining_secs );
596 0 : jsonp_double( gui->http, "downloading_incremental_snapshot_throughput", gui->summary.startup_progress.startup_incremental_snapshot_throughput );
597 0 : jsonp_ulong( gui->http, "downloading_incremental_snapshot_total_bytes", gui->summary.startup_progress.startup_incremental_snapshot_total_bytes );
598 0 : jsonp_ulong( gui->http, "downloading_incremental_snapshot_current_bytes", gui->summary.startup_progress.startup_incremental_snapshot_current_bytes );
599 0 : } else {
600 0 : jsonp_null( gui->http, "downloading_incremental_snapshot_peer" );
601 0 : jsonp_null( gui->http, "downloading_incremental_snapshot_slot" );
602 0 : jsonp_null( gui->http, "downloading_incremental_snapshot_elapsed_secs" );
603 0 : jsonp_null( gui->http, "downloading_incremental_snapshot_remaining_secs" );
604 0 : jsonp_null( gui->http, "downloading_incremental_snapshot_throughput" );
605 0 : jsonp_null( gui->http, "downloading_incremental_snapshot_total_bytes" );
606 0 : jsonp_null( gui->http, "downloading_incremental_snapshot_current_bytes" );
607 0 : }
608 :
609 0 : if( FD_LIKELY( gui->summary.startup_progress.phase>=FD_GUI_START_PROGRESS_TYPE_PROCESSING_LEDGER) ) {
610 0 : jsonp_ulong( gui->http, "ledger_slot", gui->summary.startup_progress.startup_ledger_slot );
611 0 : jsonp_ulong( gui->http, "ledger_max_slot", gui->summary.startup_progress.startup_ledger_max_slot );
612 0 : } else {
613 0 : jsonp_null( gui->http, "ledger_slot" );
614 0 : jsonp_null( gui->http, "ledger_max_slot" );
615 0 : }
616 :
617 0 : if( FD_LIKELY( gui->summary.startup_progress.phase>=FD_GUI_START_PROGRESS_TYPE_WAITING_FOR_SUPERMAJORITY ) && gui->summary.startup_progress.startup_waiting_for_supermajority_slot!=ULONG_MAX ) {
618 0 : jsonp_ulong( gui->http, "waiting_for_supermajority_slot", gui->summary.startup_progress.startup_waiting_for_supermajority_slot );
619 0 : jsonp_ulong( gui->http, "waiting_for_supermajority_stake_percent", gui->summary.startup_progress.startup_waiting_for_supermajority_stake_pct );
620 0 : } else {
621 0 : jsonp_null( gui->http, "waiting_for_supermajority_slot" );
622 0 : jsonp_null( gui->http, "waiting_for_supermajority_stake_percent" );
623 0 : }
624 0 : jsonp_close_object( gui->http );
625 0 : jsonp_close_envelope( gui->http );
626 0 : }
627 :
628 : void
629 0 : fd_gui_printf_block_engine( fd_gui_t * gui ) {
630 0 : jsonp_open_envelope( gui->http, "block_engine", "update" );
631 0 : jsonp_open_object( gui->http, "value" );
632 0 : jsonp_string( gui->http, "name", gui->block_engine.name );
633 0 : jsonp_string( gui->http, "url", gui->block_engine.url );
634 0 : jsonp_string( gui->http, "ip", gui->block_engine.ip_cstr );
635 0 : if( FD_LIKELY( gui->block_engine.status==1 ) ) jsonp_string( gui->http, "status", "connecting" );
636 0 : else if( FD_LIKELY( gui->block_engine.status==2 ) ) jsonp_string( gui->http, "status", "connected" );
637 0 : else jsonp_string( gui->http, "status", "disconnected" );
638 0 : jsonp_close_object( gui->http );
639 0 : jsonp_close_envelope( gui->http );
640 0 : }
641 :
642 : void
643 0 : fd_gui_printf_tiles( fd_gui_t * gui ) {
644 0 : jsonp_open_envelope( gui->http, "summary", "tiles" );
645 0 : jsonp_open_array( gui->http, "value" );
646 0 : for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
647 0 : fd_topo_tile_t const * tile = &gui->topo->tiles[ i ];
648 :
649 0 : if( FD_UNLIKELY( !strncmp( tile->name, "bench", 5UL ) ) ) {
650 : /* bench tiles not reported */
651 0 : continue;
652 0 : }
653 :
654 0 : jsonp_open_object( gui->http, NULL );
655 0 : jsonp_string( gui->http, "kind", tile->name );
656 0 : jsonp_ulong( gui->http, "kind_id", tile->kind_id );
657 0 : jsonp_ulong( gui->http, "pid", fd_metrics_tile( tile->metrics )[ MIDX( GAUGE, TILE, PID ) ] );
658 0 : jsonp_close_object( gui->http );
659 0 : }
660 0 : jsonp_close_array( gui->http );
661 0 : jsonp_close_envelope( gui->http );
662 0 : }
663 :
664 : void
665 0 : fd_gui_printf_schedule_strategy( fd_gui_t * gui ) {
666 0 : jsonp_open_envelope( gui->http, "summary", "schedule_strategy" );
667 0 : char mode[10];
668 0 : switch (gui->summary.schedule_strategy) {
669 0 : case 0: strncpy( mode, "perf", sizeof(mode) ); break;
670 0 : case 1: strncpy( mode, "balanced", sizeof(mode) ); break;
671 0 : case 2: strncpy( mode, "revenue", sizeof(mode) ); break;
672 0 : default: FD_LOG_ERR(("unexpected schedule_strategy %d", gui->summary.schedule_strategy));
673 0 : }
674 0 : mode[ sizeof(mode) - 1] = '\0';
675 0 : jsonp_string( gui->http, "value", mode );
676 0 : jsonp_close_envelope( gui->http );
677 0 : }
678 :
679 : void
680 0 : fd_gui_printf_identity_balance( fd_gui_t * gui ) {
681 0 : jsonp_open_envelope( gui->http, "summary", "identity_balance" );
682 0 : jsonp_ulong_as_str( gui->http, "value", gui->summary.identity_account_balance );
683 0 : jsonp_close_envelope( gui->http );
684 0 : }
685 :
686 : void
687 0 : fd_gui_printf_vote_balance( fd_gui_t * gui ) {
688 0 : jsonp_open_envelope( gui->http, "summary", "vote_balance" );
689 0 : jsonp_ulong_as_str( gui->http, "value", gui->summary.vote_account_balance );
690 0 : jsonp_close_envelope( gui->http );
691 0 : }
692 :
693 : void
694 0 : fd_gui_printf_estimated_slot_duration_nanos( fd_gui_t * gui ) {
695 0 : jsonp_open_envelope( gui->http, "summary", "estimated_slot_duration_nanos" );
696 0 : jsonp_ulong( gui->http, "value", gui->summary.estimated_slot_duration_nanos );
697 0 : jsonp_close_envelope( gui->http );
698 0 : }
699 :
700 :
701 : void
702 0 : fd_gui_printf_root_slot( fd_gui_t * gui ) {
703 0 : jsonp_open_envelope( gui->http, "summary", "root_slot" );
704 0 : jsonp_ulong( gui->http, "value", fd_ulong_if( gui->summary.slot_rooted!=ULONG_MAX, gui->summary.slot_rooted, 0UL ) );
705 0 : jsonp_close_envelope( gui->http );
706 0 : }
707 :
708 : void
709 0 : fd_gui_printf_optimistically_confirmed_slot( fd_gui_t * gui ) {
710 0 : jsonp_open_envelope( gui->http, "summary", "optimistically_confirmed_slot" );
711 0 : jsonp_ulong( gui->http, "value", fd_ulong_if( gui->summary.slot_optimistically_confirmed!=ULONG_MAX, gui->summary.slot_optimistically_confirmed, 0UL ) );
712 0 : jsonp_close_envelope( gui->http );
713 0 : }
714 :
715 : void
716 0 : fd_gui_printf_completed_slot( fd_gui_t * gui ) {
717 0 : jsonp_open_envelope( gui->http, "summary", "completed_slot" );
718 0 : jsonp_ulong( gui->http, "value", fd_ulong_if( gui->summary.slot_completed!=ULONG_MAX, gui->summary.slot_completed, 0UL ) );
719 0 : jsonp_close_envelope( gui->http );
720 0 : }
721 :
722 : void
723 0 : fd_gui_printf_estimated_slot( fd_gui_t * gui ) {
724 0 : jsonp_open_envelope( gui->http, "summary", "estimated_slot" );
725 0 : jsonp_ulong( gui->http, "value", fd_ulong_if( gui->summary.slot_estimated!=ULONG_MAX, gui->summary.slot_estimated, 0UL ) );
726 0 : jsonp_close_envelope( gui->http );
727 0 : }
728 :
729 : void
730 : fd_gui_printf_skip_rate( fd_gui_t * gui,
731 0 : ulong epoch_idx ) {
732 0 : jsonp_open_envelope( gui->http, "summary", "skip_rate" );
733 0 : jsonp_open_object( gui->http, "value" );
734 0 : jsonp_ulong( gui->http, "epoch", gui->epoch.epochs[ epoch_idx ].epoch );
735 0 : fd_http_server_printf( gui->http, "\"skip_rate\":%.7f,", !!gui->epoch.epochs[ epoch_idx ].my_total_slots ? (double)gui->epoch.epochs[ epoch_idx ].my_skipped_slots/(double)gui->epoch.epochs[ epoch_idx ].my_total_slots : 0.0 );
736 0 : jsonp_close_object( gui->http );
737 0 : jsonp_close_envelope( gui->http );
738 0 : }
739 :
740 : void
741 : fd_gui_printf_epoch( fd_gui_t * gui,
742 0 : ulong epoch_idx ) {
743 0 : jsonp_open_envelope( gui->http, "epoch", "new" );
744 0 : jsonp_open_object( gui->http, "value" );
745 0 : jsonp_ulong( gui->http, "epoch", gui->epoch.epochs[ epoch_idx ].epoch );
746 0 : if( FD_LIKELY( gui->epoch.epochs[ epoch_idx ].start_time!=LONG_MAX ) ) jsonp_ulong_as_str( gui->http, "start_time_nanos", (ulong)gui->epoch.epochs[ epoch_idx ].start_time );
747 0 : else jsonp_null( gui->http, "start_time_nanos" );
748 0 : if( FD_LIKELY( gui->epoch.epochs[ epoch_idx ].end_time!=LONG_MAX ) ) jsonp_ulong_as_str( gui->http, "end_time_nanos", (ulong)gui->epoch.epochs[ epoch_idx ].end_time );
749 0 : else jsonp_null( gui->http, "end_time_nanos" );
750 0 : jsonp_ulong( gui->http, "start_slot", gui->epoch.epochs[ epoch_idx ].start_slot );
751 0 : jsonp_ulong( gui->http, "end_slot", gui->epoch.epochs[ epoch_idx ].end_slot );
752 0 : jsonp_ulong_as_str( gui->http, "excluded_stake_lamports", 0UL );
753 0 : jsonp_open_array( gui->http, "staked_pubkeys" );
754 0 : fd_epoch_leaders_t * lsched = gui->epoch.epochs[epoch_idx].lsched;
755 0 : for( ulong i=0UL; i<lsched->pub_cnt; i++ ) {
756 0 : char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
757 0 : fd_base58_encode_32( lsched->pub[ i ].uc, NULL, identity_base58 );
758 0 : jsonp_string( gui->http, NULL, identity_base58 );
759 0 : }
760 0 : jsonp_close_array( gui->http );
761 :
762 0 : jsonp_open_array( gui->http, "staked_lamports" );
763 0 : fd_vote_stake_weight_t * stakes = gui->epoch.epochs[epoch_idx].stakes;
764 0 : for( ulong i=0UL; i<lsched->pub_cnt; i++ ) jsonp_ulong_as_str( gui->http, NULL, stakes[ i ].stake );
765 0 : jsonp_close_array( gui->http );
766 :
767 0 : jsonp_open_array( gui->http, "leader_slots" );
768 0 : for( ulong i = 0; i < lsched->sched_cnt; i++ ) jsonp_ulong( gui->http, NULL, lsched->sched[ i ] );
769 0 : jsonp_close_array( gui->http );
770 0 : jsonp_close_object( gui->http );
771 0 : jsonp_close_envelope( gui->http );
772 0 : }
773 :
774 : static void
775 : fd_gui_printf_waterfall( fd_gui_t * gui,
776 : fd_gui_txn_waterfall_t const * prev,
777 0 : fd_gui_txn_waterfall_t const * cur ) {
778 0 : jsonp_open_object( gui->http, "waterfall" );
779 0 : jsonp_open_object( gui->http, "in" );
780 0 : jsonp_ulong( gui->http, "pack_cranked", cur->in.pack_cranked - prev->in.pack_cranked );
781 0 : jsonp_ulong( gui->http, "pack_retained", prev->out.pack_retained );
782 0 : jsonp_ulong( gui->http, "resolv_retained", prev->out.resolv_retained );
783 0 : jsonp_ulong( gui->http, "quic", cur->in.quic - prev->in.quic );
784 0 : jsonp_ulong( gui->http, "udp", cur->in.udp - prev->in.udp );
785 0 : jsonp_ulong( gui->http, "gossip", cur->in.gossip - prev->in.gossip );
786 0 : jsonp_ulong( gui->http, "block_engine", cur->in.block_engine - prev->in.block_engine );
787 0 : jsonp_close_object( gui->http );
788 :
789 0 : jsonp_open_object( gui->http, "out" );
790 0 : jsonp_ulong( gui->http, "net_overrun", cur->out.net_overrun - prev->out.net_overrun );
791 0 : jsonp_ulong( gui->http, "quic_overrun", cur->out.quic_overrun - prev->out.quic_overrun );
792 0 : jsonp_ulong( gui->http, "quic_frag_drop", cur->out.quic_frag_drop - prev->out.quic_frag_drop );
793 0 : jsonp_ulong( gui->http, "quic_abandoned", cur->out.quic_abandoned - prev->out.quic_abandoned );
794 0 : jsonp_ulong( gui->http, "tpu_quic_invalid", cur->out.tpu_quic_invalid - prev->out.tpu_quic_invalid );
795 0 : jsonp_ulong( gui->http, "tpu_udp_invalid", cur->out.tpu_udp_invalid - prev->out.tpu_udp_invalid );
796 0 : jsonp_ulong( gui->http, "verify_overrun", cur->out.verify_overrun - prev->out.verify_overrun );
797 0 : jsonp_ulong( gui->http, "verify_parse", cur->out.verify_parse - prev->out.verify_parse );
798 0 : jsonp_ulong( gui->http, "verify_failed", cur->out.verify_failed - prev->out.verify_failed );
799 0 : jsonp_ulong( gui->http, "verify_duplicate", cur->out.verify_duplicate - prev->out.verify_duplicate );
800 0 : jsonp_ulong( gui->http, "dedup_duplicate", cur->out.dedup_duplicate - prev->out.dedup_duplicate );
801 0 : jsonp_ulong( gui->http, "resolv_lut_failed", cur->out.resolv_lut_failed - prev->out.resolv_lut_failed );
802 0 : jsonp_ulong( gui->http, "resolv_expired", cur->out.resolv_expired - prev->out.resolv_expired );
803 0 : jsonp_ulong( gui->http, "resolv_ancient", cur->out.resolv_ancient - prev->out.resolv_ancient );
804 0 : jsonp_ulong( gui->http, "resolv_no_ledger", cur->out.resolv_no_ledger - prev->out.resolv_no_ledger );
805 0 : jsonp_ulong( gui->http, "resolv_retained", cur->out.resolv_retained );
806 0 : jsonp_ulong( gui->http, "pack_invalid", cur->out.pack_invalid - prev->out.pack_invalid );
807 0 : jsonp_ulong( gui->http, "pack_invalid_bundle", cur->out.pack_invalid_bundle - prev->out.pack_invalid_bundle );
808 0 : jsonp_ulong( gui->http, "pack_expired", cur->out.pack_expired - prev->out.pack_expired );
809 0 : jsonp_ulong( gui->http, "pack_already_executed", cur->out.pack_already_executed - prev->out.pack_already_executed );
810 0 : jsonp_ulong( gui->http, "pack_retained", cur->out.pack_retained );
811 0 : jsonp_ulong( gui->http, "pack_wait_full", cur->out.pack_wait_full - prev->out.pack_wait_full );
812 0 : jsonp_ulong( gui->http, "pack_leader_slow", cur->out.pack_leader_slow - prev->out.pack_leader_slow );
813 0 : jsonp_ulong( gui->http, "bank_invalid", cur->out.bank_invalid - prev->out.bank_invalid );
814 0 : jsonp_ulong( gui->http, "bank_nonce_already_advanced", cur->out.bank_nonce_already_advanced - prev->out.bank_nonce_already_advanced );
815 0 : jsonp_ulong( gui->http, "bank_nonce_advance_failed", cur->out.bank_nonce_advance_failed - prev->out.bank_nonce_advance_failed );
816 0 : jsonp_ulong( gui->http, "bank_nonce_wrong_blockhash", cur->out.bank_nonce_wrong_blockhash - prev->out.bank_nonce_wrong_blockhash );
817 0 : jsonp_ulong( gui->http, "block_success", cur->out.block_success - prev->out.block_success );
818 0 : jsonp_ulong( gui->http, "block_fail", cur->out.block_fail - prev->out.block_fail );
819 0 : jsonp_close_object( gui->http );
820 0 : jsonp_close_object( gui->http );
821 0 : }
822 :
823 : void
824 : fd_gui_printf_live_txn_waterfall( fd_gui_t * gui,
825 : fd_gui_txn_waterfall_t const * prev,
826 : fd_gui_txn_waterfall_t const * cur,
827 0 : ulong next_leader_slot ) {
828 0 : jsonp_open_envelope( gui->http, "summary", "live_txn_waterfall" );
829 0 : jsonp_open_object( gui->http, "value" );
830 0 : jsonp_ulong( gui->http, "next_leader_slot", next_leader_slot );
831 0 : fd_gui_printf_waterfall( gui, prev, cur );
832 0 : jsonp_close_object( gui->http );
833 0 : jsonp_close_envelope( gui->http );
834 0 : }
835 :
836 : static void
837 : fd_gui_printf_network_metrics( fd_gui_t * gui,
838 0 : fd_gui_network_stats_t const * cur ) {
839 0 : jsonp_open_array( gui->http, "ingress" );
840 0 : jsonp_ulong( gui->http, NULL, cur->in.turbine );
841 0 : jsonp_ulong( gui->http, NULL, cur->in.gossip );
842 0 : jsonp_ulong( gui->http, NULL, cur->in.tpu );
843 0 : jsonp_ulong( gui->http, NULL, cur->in.repair );
844 0 : jsonp_ulong( gui->http, NULL, cur->in.metric );
845 0 : jsonp_close_array( gui->http );
846 0 : jsonp_open_array( gui->http, "egress" );
847 0 : jsonp_ulong( gui->http, NULL, cur->out.turbine );
848 0 : jsonp_ulong( gui->http, NULL, cur->out.gossip );
849 0 : jsonp_ulong( gui->http, NULL, cur->out.tpu );
850 0 : jsonp_ulong( gui->http, NULL, cur->out.repair );
851 0 : jsonp_ulong( gui->http, NULL, cur->out.metric );
852 0 : jsonp_close_array( gui->http );
853 0 : }
854 :
855 : void
856 : fd_gui_printf_live_network_metrics( fd_gui_t * gui,
857 0 : fd_gui_network_stats_t const * cur ) {
858 0 : jsonp_open_envelope( gui->http, "summary", "live_network_metrics" );
859 0 : jsonp_open_object( gui->http, "value" );
860 0 : fd_gui_printf_network_metrics( gui, cur );
861 0 : jsonp_close_object( gui->http );
862 0 : jsonp_close_envelope( gui->http );
863 0 : }
864 :
865 : static void
866 : fd_gui_printf_tile_stats( fd_gui_t * gui,
867 : fd_gui_tile_stats_t const * prev,
868 0 : fd_gui_tile_stats_t const * cur ) {
869 0 : jsonp_open_object( gui->http, "tile_primary_metric" );
870 0 : jsonp_ulong( gui->http, "quic", cur->quic_conn_cnt );
871 0 : jsonp_double( gui->http, "bundle_rtt_smoothed_millis", (double)(cur->bundle_rtt_smoothed_nanos) / 1000000.0 );
872 :
873 0 : fd_histf_t bundle_rx_delay_hist_delta[ 1 ];
874 0 : fd_histf_subtract( &cur->bundle_rx_delay_hist, &prev->bundle_rx_delay_hist, bundle_rx_delay_hist_delta );
875 0 : ulong bundle_rx_delay_nanos_p90 = fd_histf_percentile( bundle_rx_delay_hist_delta, 90U, ULONG_MAX );
876 0 : jsonp_double( gui->http, "bundle_rx_delay_millis_p90", fd_double_if(bundle_rx_delay_nanos_p90==ULONG_MAX, 0.0, (double)(bundle_rx_delay_nanos_p90) / 1000000.0 ));
877 :
878 0 : if( FD_LIKELY( cur->sample_time_nanos>prev->sample_time_nanos ) ) {
879 0 : jsonp_ulong( gui->http, "net_in", (ulong)((double)(cur->net_in_rx_bytes - prev->net_in_rx_bytes) * 1000000000.0 / (double)(cur->sample_time_nanos - prev->sample_time_nanos) ));
880 0 : jsonp_ulong( gui->http, "net_out", (ulong)((double)(cur->net_out_tx_bytes - prev->net_out_tx_bytes) * 1000000000.0 / (double)(cur->sample_time_nanos - prev->sample_time_nanos) ));
881 0 : } else {
882 0 : jsonp_ulong( gui->http, "net_in", 0 );
883 0 : jsonp_ulong( gui->http, "net_out", 0 );
884 0 : }
885 0 : if( FD_LIKELY( cur->verify_total_cnt>prev->verify_total_cnt ) ) {
886 0 : jsonp_double( gui->http, "verify", (double)(cur->verify_drop_cnt-prev->verify_drop_cnt) / (double)(cur->verify_total_cnt-prev->verify_total_cnt) );
887 0 : } else {
888 0 : jsonp_double( gui->http, "verify", 0.0 );
889 0 : }
890 0 : if( FD_LIKELY( cur->dedup_total_cnt>prev->dedup_total_cnt ) ) {
891 0 : jsonp_double( gui->http, "dedup", (double)(cur->dedup_drop_cnt-prev->dedup_drop_cnt) / (double)(cur->dedup_total_cnt-prev->dedup_total_cnt) );
892 0 : } else {
893 0 : jsonp_double( gui->http, "dedup", 0.0 );
894 0 : }
895 0 : jsonp_ulong( gui->http, "bank", cur->bank_txn_exec_cnt - prev->bank_txn_exec_cnt );
896 0 : jsonp_double( gui->http, "pack", !cur->pack_buffer_capacity ? 1.0 : (double)cur->pack_buffer_cnt/(double)cur->pack_buffer_capacity );
897 0 : jsonp_double( gui->http, "poh", 0.0 );
898 0 : jsonp_double( gui->http, "shred", 0.0 );
899 0 : jsonp_double( gui->http, "store", 0.0 );
900 0 : jsonp_close_object( gui->http );
901 0 : }
902 :
903 : void
904 : fd_gui_printf_live_tile_stats( fd_gui_t * gui,
905 : fd_gui_tile_stats_t const * prev,
906 0 : fd_gui_tile_stats_t const * cur ) {
907 0 : jsonp_open_envelope( gui->http, "summary", "live_tile_primary_metric" );
908 0 : jsonp_open_object( gui->http, "value" );
909 0 : jsonp_ulong( gui->http, "next_leader_slot", 0UL );
910 0 : fd_gui_printf_tile_stats( gui, prev, cur );
911 0 : jsonp_close_object( gui->http );
912 0 : jsonp_close_envelope( gui->http );
913 0 : }
914 :
915 : static void
916 : fd_gui_printf_tile_timers( fd_gui_t * gui,
917 : fd_gui_tile_timers_t const * prev,
918 0 : fd_gui_tile_timers_t const * cur ) {
919 0 : for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
920 0 : fd_topo_tile_t const * tile = &gui->topo->tiles[ i ];
921 :
922 0 : if( FD_UNLIKELY( !strncmp( tile->name, "bench", 5UL ) ) ) {
923 : /* bench tiles not reported */
924 0 : continue;
925 0 : }
926 :
927 0 : ulong cur_total = 0UL;
928 0 : for( ulong j=0UL; j<FD_METRICS_ENUM_TILE_REGIME_CNT; j++ ) cur_total += cur[ i ].timers[ j ];
929 :
930 0 : ulong prev_total = 0UL;
931 0 : for( ulong j=0UL; j<FD_METRICS_ENUM_TILE_REGIME_CNT; j++ ) prev_total += prev[ i ].timers[ j ];
932 :
933 0 : double idle_ratio;
934 0 : if( FD_UNLIKELY( cur_total==prev_total ) ) {
935 : /* The tile didn't sample timers since the last sample, unclear what
936 : idleness should be so send -1. NaN would be better but no NaN in
937 : JSON. */
938 0 : idle_ratio = -1;
939 0 : } else {
940 0 : ulong idle_time = cur[ i ].timers[ FD_METRICS_ENUM_TILE_REGIME_V_CAUGHT_UP_POSTFRAG_IDX ] - prev[ i ].timers[ FD_METRICS_ENUM_TILE_REGIME_V_CAUGHT_UP_POSTFRAG_IDX ];
941 0 : ulong backpressure_time = cur[ i ].timers[ FD_METRICS_ENUM_TILE_REGIME_V_BACKPRESSURE_PREFRAG_IDX ] - prev[ i ].timers[ FD_METRICS_ENUM_TILE_REGIME_V_BACKPRESSURE_PREFRAG_IDX ];
942 0 : idle_ratio = (double)(idle_time+backpressure_time) / (double)(cur_total - prev_total);
943 0 : }
944 :
945 0 : jsonp_double( gui->http, NULL, idle_ratio );
946 0 : }
947 0 : }
948 :
949 : static void
950 : fd_gui_printf_tile_metrics( fd_gui_t * gui,
951 : fd_gui_tile_timers_t const * prev,
952 0 : fd_gui_tile_timers_t const * cur ) {
953 0 : jsonp_open_array( gui->http, "timers" );
954 0 : for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
955 0 : fd_topo_tile_t const * tile = &gui->topo->tiles[ i ];
956 :
957 0 : if( FD_UNLIKELY( !strncmp( tile->name, "bench", 5UL ) ) ) {
958 : /* bench tiles not reported */
959 0 : jsonp_null( gui->http, NULL );
960 0 : continue;
961 0 : }
962 :
963 0 : ulong cur_total = 0UL;
964 0 : for( ulong j=0UL; j<FD_METRICS_ENUM_TILE_REGIME_CNT; j++ ) cur_total += cur[ i ].timers[ j ];
965 :
966 0 : ulong prev_total = 0UL;
967 0 : for( ulong j=0UL; j<FD_METRICS_ENUM_TILE_REGIME_CNT; j++ ) prev_total += prev[ i ].timers[ j ];
968 :
969 0 : if( FD_UNLIKELY( cur_total==prev_total ) ) {
970 0 : jsonp_null( gui->http, NULL );
971 0 : } else {
972 0 : jsonp_open_array( gui->http, NULL );
973 0 : for (ulong j = 0UL; j<FD_METRICS_ENUM_TILE_REGIME_CNT; j++) {
974 0 : double percent = ((double)(cur[ i ].timers[ j ] - prev[ i ].timers[ j ]) / (double)(cur_total-prev_total)) * 100.0;
975 0 : double percent_trunc = (double)((long)(percent * 100.0)) / 100.0;
976 0 : jsonp_double( gui->http, NULL, percent_trunc );
977 0 : }
978 0 : jsonp_close_array( gui->http );
979 0 : }
980 0 : }
981 0 : jsonp_close_array( gui->http );
982 :
983 0 : jsonp_open_array( gui->http, "sched_timers" );
984 0 : for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
985 0 : fd_topo_tile_t const * tile = &gui->topo->tiles[ i ];
986 :
987 0 : if( FD_UNLIKELY( !strncmp( tile->name, "bench", 5UL ) ) ) {
988 : /* bench tiles not reported */
989 0 : jsonp_null( gui->http, NULL );
990 0 : continue;
991 0 : }
992 :
993 0 : ulong cur_total = 0UL;
994 0 : for( ulong j=0UL; j<FD_METRICS_ENUM_CPU_REGIME_CNT; j++ ) cur_total += cur[ i ].sched_timers[ j ];
995 :
996 0 : ulong prev_total = 0UL;
997 0 : for( ulong j=0UL; j<FD_METRICS_ENUM_CPU_REGIME_CNT; j++ ) prev_total += prev[ i ].sched_timers[ j ];
998 :
999 0 : if( FD_UNLIKELY( cur_total==prev_total ) ) {
1000 0 : jsonp_null( gui->http, NULL );
1001 0 : } else {
1002 0 : jsonp_open_array( gui->http, NULL );
1003 0 : for (ulong j = 0UL; j<FD_METRICS_ENUM_CPU_REGIME_CNT; j++) {
1004 0 : double percent = ((double)(cur[ i ].sched_timers[ j ] - prev[ i ].sched_timers[ j ]) / (double)(cur_total-prev_total)) * 100.0;
1005 0 : double percent_trunc = (double)((long)(percent * 100.0)) / 100.0;
1006 0 : jsonp_double( gui->http, NULL, percent_trunc );
1007 0 : }
1008 0 : jsonp_close_array( gui->http );
1009 0 : }
1010 0 : }
1011 0 : jsonp_close_array( gui->http );
1012 :
1013 0 : jsonp_open_array( gui->http, "in_backp" );
1014 0 : for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
1015 0 : jsonp_bool( gui->http, NULL, cur[ i ].in_backp );
1016 0 : }
1017 0 : jsonp_close_array( gui->http );
1018 0 : jsonp_open_array( gui->http, "backp_msgs" );
1019 0 : for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
1020 0 : jsonp_ulong( gui->http, NULL, cur[ i ].backp_cnt );
1021 0 : }
1022 0 : jsonp_close_array( gui->http );
1023 0 : jsonp_open_array( gui->http, "alive" );
1024 0 : for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
1025 : /* We use a longer sampling window for this metric to minimize
1026 : false positives */
1027 0 : jsonp_ulong( gui->http, NULL, fd_ulong_if( cur[ i ].status==2U, 2UL, (ulong)(cur[ i ].heartbeat>prev[ i ].heartbeat) ) );
1028 0 : }
1029 0 : jsonp_close_array( gui->http );
1030 0 : jsonp_open_array( gui->http, "nvcsw" );
1031 0 : for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
1032 0 : jsonp_ulong( gui->http, NULL, cur[ i ].nvcsw );
1033 0 : }
1034 0 : jsonp_close_array( gui->http );
1035 0 : jsonp_open_array( gui->http, "nivcsw" );
1036 0 : for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
1037 0 : jsonp_ulong( gui->http, NULL, cur[ i ].nivcsw );
1038 0 : }
1039 0 : jsonp_close_array( gui->http );
1040 0 : jsonp_open_array( gui->http, "minflt" );
1041 0 : for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
1042 0 : jsonp_ulong( gui->http, NULL, cur[ i ].minflt );
1043 0 : }
1044 0 : jsonp_close_array( gui->http );
1045 0 : jsonp_open_array( gui->http, "majflt" );
1046 0 : for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
1047 0 : jsonp_ulong( gui->http, NULL, cur[ i ].majflt );
1048 0 : }
1049 0 : jsonp_close_array( gui->http );
1050 0 : jsonp_open_array( gui->http, "last_cpu" );
1051 0 : for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
1052 0 : jsonp_ulong( gui->http, NULL, cur[ i ].last_cpu );
1053 0 : }
1054 0 : jsonp_close_array( gui->http );
1055 0 : }
1056 :
1057 : void
1058 0 : fd_gui_printf_live_tile_timers( fd_gui_t * gui ) {
1059 0 : jsonp_open_envelope( gui->http, "summary", "live_tile_timers" );
1060 0 : jsonp_open_array( gui->http, "value" );
1061 0 : fd_gui_tile_timers_t * cur = gui->summary.tile_timers_snap + ((gui->summary.tile_timers_snap_idx+(FD_GUI_TILE_TIMER_SNAP_CNT-1UL))%FD_GUI_TILE_TIMER_SNAP_CNT) * gui->tile_cnt;
1062 0 : fd_gui_tile_timers_t * prev = gui->summary.tile_timers_snap + ((gui->summary.tile_timers_snap_idx+(FD_GUI_TILE_TIMER_SNAP_CNT-2UL))%FD_GUI_TILE_TIMER_SNAP_CNT) * gui->tile_cnt;
1063 0 : fd_gui_printf_tile_timers( gui, prev, cur );
1064 0 : jsonp_close_array( gui->http );
1065 0 : jsonp_close_envelope( gui->http );
1066 0 : }
1067 :
1068 : void
1069 0 : fd_gui_printf_live_tile_metrics( fd_gui_t * gui ) {
1070 0 : fd_gui_tile_timers_t * cur = gui->summary.tile_timers_snap + ((gui->summary.tile_timers_snap_idx+(FD_GUI_TILE_TIMER_SNAP_CNT-1UL))%FD_GUI_TILE_TIMER_SNAP_CNT) * gui->tile_cnt;
1071 0 : fd_gui_tile_timers_t * prev = gui->summary.tile_timers_snap + ((gui->summary.tile_timers_snap_idx+(FD_GUI_TILE_TIMER_SNAP_CNT-2UL))%FD_GUI_TILE_TIMER_SNAP_CNT) * gui->tile_cnt;
1072 0 : jsonp_open_envelope( gui->http, "summary", "live_tile_metrics" );
1073 0 : jsonp_open_object( gui->http, "value" );
1074 0 : fd_gui_printf_tile_metrics( gui, prev, cur );
1075 0 : jsonp_close_object( gui->http );
1076 0 : jsonp_close_envelope( gui->http );
1077 0 : }
1078 :
1079 : void
1080 0 : fd_gui_printf_estimated_tps( fd_gui_t * gui ) {
1081 0 : ulong idx = (gui->summary.estimated_tps_history_idx+FD_GUI_TPS_HISTORY_SAMPLE_CNT-1UL) % FD_GUI_TPS_HISTORY_SAMPLE_CNT;
1082 :
1083 0 : jsonp_open_envelope( gui->http, "summary", "estimated_tps" );
1084 0 : jsonp_open_object( gui->http, "value" );
1085 0 : ulong vote_cnt = gui->summary.estimated_tps_history[ idx ].vote_failed
1086 0 : + gui->summary.estimated_tps_history[ idx ].vote_success;
1087 0 : ulong total_cnt = vote_cnt
1088 0 : + gui->summary.estimated_tps_history[ idx ].nonvote_success
1089 0 : + gui->summary.estimated_tps_history[ idx ].nonvote_failed;
1090 0 : jsonp_double( gui->http, "total", (double)total_cnt/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
1091 0 : jsonp_double( gui->http, "vote", (double)vote_cnt/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
1092 0 : jsonp_double( gui->http, "nonvote_success", (double)gui->summary.estimated_tps_history[ idx ].nonvote_success/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
1093 0 : jsonp_double( gui->http, "nonvote_failed", (double)gui->summary.estimated_tps_history[ idx ].nonvote_failed/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
1094 0 : jsonp_close_object( gui->http );
1095 0 : jsonp_close_envelope( gui->http );
1096 0 : }
1097 :
1098 : void
1099 0 : fd_gui_printf_live_program_cache( fd_gui_t * gui ) {
1100 0 : fd_topo_t const * topo = gui->topo;
1101 :
1102 0 : ulong hits = 0UL;
1103 0 : ulong lookups = 0UL;
1104 0 : ulong insertions = 0UL;
1105 0 : ulong insertion_bytes = 0UL;
1106 0 : ulong evictions = 0UL;
1107 0 : ulong eviction_bytes = 0UL;
1108 0 : ulong spills = 0UL;
1109 0 : ulong spill_bytes = 0UL;
1110 :
1111 0 : for( ulong i=0UL; i<gui->summary.execrp_tile_cnt; i++ ) {
1112 0 : fd_topo_tile_t const * execrp = &topo->tiles[ fd_topo_find_tile( topo, "execrp", i ) ];
1113 0 : volatile ulong const * metrics = fd_metrics_tile( execrp->metrics );
1114 :
1115 0 : hits += metrics[ MIDX( COUNTER, EXECRP, PROGCACHE_HITS ) ];
1116 0 : lookups += metrics[ MIDX( COUNTER, EXECRP, PROGCACHE_LOOKUPS ) ];
1117 0 : insertions += metrics[ MIDX( COUNTER, EXECRP, PROGCACHE_FILLS ) ];
1118 0 : insertion_bytes += metrics[ MIDX( COUNTER, EXECRP, PROGCACHE_FILL_BYTES ) ];
1119 0 : evictions += metrics[ MIDX( COUNTER, EXECRP, PROGCACHE_EVICTIONS ) ];
1120 0 : eviction_bytes += metrics[ MIDX( COUNTER, EXECRP, PROGCACHE_EVICTION_BYTES ) ];
1121 0 : spills += metrics[ MIDX( COUNTER, EXECRP, PROGCACHE_SPILLS ) ];
1122 0 : spill_bytes += metrics[ MIDX( COUNTER, EXECRP, PROGCACHE_SPILL_BYTES ) ];
1123 0 : }
1124 :
1125 0 : ulong free_bytes = 0UL;
1126 0 : ulong size_bytes = 0UL;
1127 :
1128 0 : fd_topo_tile_t const * replay = &topo->tiles[ fd_topo_find_tile( topo, "replay", 0UL ) ];
1129 0 : volatile ulong const * replay_metrics = fd_metrics_tile( replay->metrics );
1130 :
1131 0 : free_bytes = replay_metrics[ MIDX( GAUGE, REPLAY, PROGCACHE_FREE_BYTES ) ];
1132 0 : size_bytes = replay_metrics[ MIDX( GAUGE, REPLAY, PROGCACHE_SIZE_BYTES ) ];
1133 :
1134 0 : jsonp_open_envelope( gui->http, "summary", "live_program_cache" );
1135 0 : jsonp_open_object( gui->http, "value" );
1136 0 : jsonp_ulong( gui->http, "hits", hits );
1137 0 : jsonp_ulong( gui->http, "lookups", lookups );
1138 0 : jsonp_ulong( gui->http, "insertions", insertions );
1139 0 : jsonp_ulong( gui->http, "insertion_bytes", insertion_bytes );
1140 0 : jsonp_ulong( gui->http, "evictions", evictions );
1141 0 : jsonp_ulong( gui->http, "eviction_bytes", eviction_bytes );
1142 0 : jsonp_ulong( gui->http, "spills", spills );
1143 0 : jsonp_ulong( gui->http, "spill_bytes", spill_bytes );
1144 0 : jsonp_ulong( gui->http, "free_bytes", free_bytes );
1145 0 : jsonp_ulong( gui->http, "size_bytes", size_bytes );
1146 0 : jsonp_close_object( gui->http );
1147 0 : jsonp_close_envelope( gui->http );
1148 0 : }
1149 :
1150 : static int
1151 : fd_gui_gossip_contains( fd_gui_t const * gui,
1152 0 : uchar const * pubkey ) {
1153 0 : for( ulong i=0UL; i<gui->gossip.peer_cnt; i++ ) {
1154 0 : if( FD_UNLIKELY( !memcmp( gui->gossip.peers[ i ].pubkey->uc, pubkey, 32 ) ) ) return 1;
1155 0 : }
1156 0 : return 0;
1157 0 : }
1158 :
1159 : static int
1160 : fd_gui_vote_acct_contains( fd_gui_t const * gui,
1161 0 : uchar const * pubkey ) {
1162 0 : for( ulong i=0UL; i<gui->vote_account.vote_account_cnt; i++ ) {
1163 0 : if( FD_UNLIKELY( !memcmp( gui->vote_account.vote_accounts[ i ].pubkey, pubkey, 32 ) ) ) return 1;
1164 0 : }
1165 0 : return 0;
1166 0 : }
1167 :
1168 : static int
1169 : fd_gui_validator_info_contains( fd_gui_t const * gui,
1170 0 : uchar const * pubkey ) {
1171 0 : for( ulong i=0UL; i<gui->validator_info.info_cnt; i++ ) {
1172 0 : if( FD_UNLIKELY( !memcmp( gui->validator_info.info[ i ].pubkey, pubkey, 32 ) ) ) return 1;
1173 0 : }
1174 0 : return 0;
1175 0 : }
1176 :
1177 : static void
1178 : fd_gui_printf_peer( fd_gui_t * gui,
1179 0 : uchar const * identity_pubkey ) {
1180 0 : ulong gossip_idx = ULONG_MAX;
1181 0 : ulong info_idx = ULONG_MAX;
1182 0 : ulong vote_idxs[ FD_GUI_MAX_PEER_CNT ] = {0};
1183 0 : ulong vote_idx_cnt = 0UL;
1184 :
1185 0 : for( ulong i=0UL; i<gui->gossip.peer_cnt; i++ ) {
1186 0 : if( FD_UNLIKELY( !memcmp( gui->gossip.peers[ i ].pubkey->uc, identity_pubkey, 32 ) ) ) {
1187 0 : gossip_idx = i;
1188 0 : break;
1189 0 : }
1190 0 : }
1191 :
1192 0 : for( ulong i=0UL; i<gui->validator_info.info_cnt; i++ ) {
1193 0 : if( FD_UNLIKELY( !memcmp( gui->validator_info.info[ i ].pubkey, identity_pubkey, 32 ) ) ) {
1194 0 : info_idx = i;
1195 0 : break;
1196 0 : }
1197 0 : }
1198 :
1199 0 : for( ulong i=0UL; i<gui->vote_account.vote_account_cnt; i++ ) {
1200 0 : if( FD_UNLIKELY( !memcmp( gui->vote_account.vote_accounts[ i ].pubkey, identity_pubkey, 32 ) ) ) {
1201 0 : vote_idxs[ vote_idx_cnt++ ] = i;
1202 0 : }
1203 0 : }
1204 :
1205 0 : jsonp_open_object( gui->http, NULL );
1206 :
1207 0 : char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
1208 0 : fd_base58_encode_32( identity_pubkey, NULL, identity_base58 );
1209 0 : jsonp_string( gui->http, "identity_pubkey", identity_base58 );
1210 :
1211 0 : if( FD_UNLIKELY( gossip_idx==ULONG_MAX ) ) {
1212 0 : jsonp_string( gui->http, "gossip", NULL );
1213 0 : } else {
1214 0 : jsonp_open_object( gui->http, "gossip" );
1215 :
1216 0 : char version[ 64UL ];
1217 0 : FD_TEST( fd_gossip_version_cstr( gui->gossip.peers[ gossip_idx ].version.major, gui->gossip.peers[ gossip_idx ].version.minor, gui->gossip.peers[ gossip_idx ].version.patch, version, sizeof( version ) ) );
1218 0 : jsonp_string( gui->http, "version", version );
1219 0 : jsonp_null( gui->http, "client_id" ); /* TODO: Frankendancer support */
1220 0 : jsonp_ulong( gui->http, "feature_set", gui->gossip.peers[ gossip_idx ].version.feature_set );
1221 0 : jsonp_ulong( gui->http, "wallclock", gui->gossip.peers[ gossip_idx ].wallclock );
1222 0 : jsonp_ulong( gui->http, "shred_version", gui->gossip.peers[ gossip_idx ].shred_version );
1223 0 : jsonp_open_object( gui->http, "sockets" );
1224 0 : for( ulong j=0UL; j<12UL; j++ ) {
1225 0 : if( FD_LIKELY( !gui->gossip.peers[ gossip_idx ].sockets[ j ].ipv4 && !gui->gossip.peers[ gossip_idx ].sockets[ j ].port ) ) continue;
1226 0 : char const * tag;
1227 0 : switch( j ) {
1228 0 : case 0: tag = "gossip"; break;
1229 0 : case 1: tag = "rpc"; break;
1230 0 : case 2: tag = "rpc_pubsub"; break;
1231 0 : case 3: tag = "serve_repair"; break;
1232 0 : case 4: tag = "serve_repair_quic"; break;
1233 0 : case 5: tag = "tpu"; break;
1234 0 : case 6: tag = "tpu_quic"; break;
1235 0 : case 7: tag = "tvu"; break;
1236 0 : case 8: tag = "tvu_quic"; break;
1237 0 : case 9: tag = "tpu_forwards"; break;
1238 0 : case 10: tag = "tpu_forwards_quic"; break;
1239 0 : case 11: tag = "tpu_vote"; break;
1240 0 : }
1241 0 : char line[ 64 ];
1242 0 : FD_TEST( fd_cstr_printf( line, sizeof( line ), NULL, FD_IP4_ADDR_FMT ":%u", FD_IP4_ADDR_FMT_ARGS(gui->gossip.peers[ gossip_idx ].sockets[ j ].ipv4 ), gui->gossip.peers[ gossip_idx ].sockets[ j ].port ) );
1243 0 : jsonp_string( gui->http, tag, line );
1244 0 : }
1245 0 : jsonp_close_object( gui->http );
1246 :
1247 0 : jsonp_close_object( gui->http );
1248 0 : }
1249 :
1250 0 : jsonp_open_array( gui->http, "vote" );
1251 0 : ulong vote_idx_cnt_bounded = fd_ulong_min( vote_idx_cnt, 5UL );
1252 0 : for( ulong i=0UL; i<vote_idx_cnt_bounded; i++ ) {
1253 0 : jsonp_open_object( gui->http, NULL );
1254 0 : char vote_account_base58[ FD_BASE58_ENCODED_32_SZ ];
1255 0 : fd_base58_encode_32( gui->vote_account.vote_accounts[ vote_idxs[ i ] ].vote_account->uc, NULL, vote_account_base58 );
1256 0 : jsonp_string( gui->http, "vote_account", vote_account_base58 );
1257 0 : jsonp_ulong_as_str( gui->http, "activated_stake", gui->vote_account.vote_accounts[ vote_idxs[ i ] ].activated_stake );
1258 0 : jsonp_ulong( gui->http, "last_vote", gui->vote_account.vote_accounts[ vote_idxs[ i ] ].last_vote );
1259 0 : jsonp_ulong( gui->http, "root_slot", gui->vote_account.vote_accounts[ vote_idxs[ i ] ].root_slot );
1260 0 : jsonp_ulong( gui->http, "epoch_credits", gui->vote_account.vote_accounts[ vote_idxs[ i ] ].epoch_credits );
1261 0 : jsonp_ulong( gui->http, "commission", gui->vote_account.vote_accounts[ vote_idxs[ i ] ].commission );
1262 0 : jsonp_bool( gui->http, "delinquent", gui->vote_account.vote_accounts[ vote_idxs[ i ] ].delinquent );
1263 0 : jsonp_close_object( gui->http );
1264 0 : }
1265 0 : jsonp_close_array( gui->http );
1266 :
1267 0 : if( FD_UNLIKELY( info_idx==ULONG_MAX ) ) {
1268 0 : jsonp_string( gui->http, "info", NULL );
1269 0 : } else {
1270 0 : jsonp_open_object( gui->http, "info" );
1271 0 : jsonp_string( gui->http, "name", gui->validator_info.info[ info_idx ].name );
1272 0 : jsonp_string( gui->http, "details", gui->validator_info.info[ info_idx ].details );
1273 0 : jsonp_string( gui->http, "website", gui->validator_info.info[ info_idx ].website );
1274 0 : jsonp_string( gui->http, "icon_url", gui->validator_info.info[ info_idx ].icon_uri );
1275 0 : jsonp_string( gui->http, "keybase_username", "" );
1276 0 : jsonp_close_object( gui->http );
1277 0 : }
1278 :
1279 0 : jsonp_close_object( gui->http );
1280 0 : }
1281 :
1282 : static void
1283 : peers_printf_node( fd_gui_peers_ctx_t * peers,
1284 0 : ulong contact_info_table_idx ) {
1285 0 : fd_gui_peers_node_t * peer = &peers->contact_info_table[ contact_info_table_idx ];
1286 :
1287 0 : jsonp_open_object( peers->http, NULL );
1288 :
1289 0 : char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
1290 0 : fd_base58_encode_32( peer->pubkey.uc, NULL, identity_base58 );
1291 0 : jsonp_string( peers->http, "identity_pubkey", identity_base58 );
1292 :
1293 0 : jsonp_open_object( peers->http, "gossip" );
1294 :
1295 0 : char version[ 64UL ];
1296 0 : FD_TEST( fd_gossip_version_cstr( peer->contact_info.version.major, peer->contact_info.version.minor, peer->contact_info.version.patch, version, sizeof( version ) ) );
1297 0 : jsonp_string( peers->http, "version", version );
1298 0 : jsonp_ulong( peers->http, "client_id", peer->contact_info.version.client );
1299 0 : jsonp_ulong( peers->http, "feature_set", peer->contact_info.version.feature_set );
1300 0 : jsonp_long( peers->http, "wallclock", peer->wallclock_nanos );
1301 0 : jsonp_ulong( peers->http, "shred_version", peer->contact_info.shred_version );
1302 0 : jsonp_open_object( peers->http, "sockets" );
1303 0 : for( ulong j=0UL; j<FD_GOSSIP_CONTACT_INFO_SOCKET_CNT; j++ ) {
1304 0 : char const * tag;
1305 0 : switch( j ) {
1306 0 : case FD_GOSSIP_CONTACT_INFO_SOCKET_GOSSIP: tag = "gossip"; break;
1307 0 : case FD_GOSSIP_CONTACT_INFO_SOCKET_SERVE_REPAIR_QUIC: tag = "serve_repair_quic"; break;
1308 0 : case FD_GOSSIP_CONTACT_INFO_SOCKET_RPC: tag = "rpc"; break;
1309 0 : case FD_GOSSIP_CONTACT_INFO_SOCKET_RPC_PUBSUB: tag = "rpc_pubsub"; break;
1310 0 : case FD_GOSSIP_CONTACT_INFO_SOCKET_SERVE_REPAIR: tag = "serve_repair"; break;
1311 0 : case FD_GOSSIP_CONTACT_INFO_SOCKET_TPU: tag = "tpu"; break;
1312 0 : case FD_GOSSIP_CONTACT_INFO_SOCKET_TPU_FORWARDS: tag = "tpu_forwards"; break;
1313 0 : case FD_GOSSIP_CONTACT_INFO_SOCKET_TPU_FORWARDS_QUIC: tag = "tpu_forwards_quic"; break;
1314 0 : case FD_GOSSIP_CONTACT_INFO_SOCKET_TPU_QUIC: tag = "tpu_quic"; break;
1315 0 : case FD_GOSSIP_CONTACT_INFO_SOCKET_TPU_VOTE: tag = "tpu_vote"; break;
1316 0 : case FD_GOSSIP_CONTACT_INFO_SOCKET_TVU: tag = "tvu"; break;
1317 0 : case FD_GOSSIP_CONTACT_INFO_SOCKET_TVU_QUIC: tag = "tvu_quic"; break;
1318 0 : case FD_GOSSIP_CONTACT_INFO_SOCKET_TPU_VOTE_QUIC: tag = "tpu_vote_quic"; break;
1319 0 : case FD_GOSSIP_CONTACT_INFO_SOCKET_ALPENGLOW: tag = "alpenglow"; break;
1320 0 : default: tag = "unknown"; break;
1321 0 : }
1322 0 : uint ip4 = peer->contact_info.sockets[ j ].is_ipv6 ? 0U : peer->contact_info.sockets[ j ].ip4;
1323 0 : char line[ 64 ];
1324 0 : FD_TEST( fd_cstr_printf( line, sizeof( line ), NULL, FD_IP4_ADDR_FMT ":%hu", FD_IP4_ADDR_FMT_ARGS( ip4 ), fd_ushort_bswap( peer->contact_info.sockets[ j ].port ) ) );
1325 0 : jsonp_string( peers->http, tag, line );
1326 0 : }
1327 0 : jsonp_close_object( peers->http );
1328 :
1329 0 : if( FD_LIKELY( peer->country_code_idx!=UCHAR_MAX ) ) {
1330 0 : jsonp_string( peers->http, "country_code", peers->dbip.country_code[ peer->country_code_idx ] );
1331 0 : } else {
1332 0 : jsonp_null( peers->http, "country_code" );
1333 0 : }
1334 :
1335 0 : if( FD_LIKELY( peer->city_name_idx!=UINT_MAX ) ) {
1336 0 : jsonp_string( peers->http, "city_name", peers->dbip.city_name[ peer->city_name_idx ] );
1337 0 : } else {
1338 0 : jsonp_null( peers->http, "city_name" );
1339 0 : }
1340 :
1341 0 : jsonp_close_object( peers->http );
1342 :
1343 0 : if( FD_LIKELY( !peer->has_vote_info ) ) {
1344 0 : jsonp_open_array( peers->http, "vote" );
1345 0 : jsonp_close_array( peers->http );
1346 0 : } else {
1347 0 : jsonp_open_array( peers->http, "vote" );
1348 0 : jsonp_open_object( peers->http, NULL );
1349 0 : char vote_account_base58[ FD_BASE58_ENCODED_32_SZ ];
1350 0 : fd_base58_encode_32( peer->vote_account.uc, NULL, vote_account_base58 );
1351 0 : jsonp_string( peers->http, "vote_account", vote_account_base58 );
1352 0 : jsonp_ulong_as_str( peers->http, "activated_stake", fd_ulong_if( peer->stake==ULONG_MAX, 0UL, peer->stake ) );
1353 0 : jsonp_ulong( peers->http, "last_vote", 0UL ); /* todo: deprecate */
1354 0 : jsonp_ulong( peers->http, "epoch_credits", 0UL ); /* todo: deprecate */
1355 0 : jsonp_ulong( peers->http, "commission", 0UL ); /* todo: deprecate */
1356 0 : jsonp_ulong( peers->http, "root_slot", 0UL ); /* todo: deprecate */
1357 0 : jsonp_bool( peers->http, "delinquent", peer->delinquent );
1358 0 : jsonp_close_object( peers->http );
1359 0 : jsonp_close_array( peers->http );
1360 0 : }
1361 :
1362 0 : fd_gui_config_parse_info_t * node_info = fd_gui_peers_node_info_map_ele_query( peers->node_info_map, &peer->pubkey, NULL, peers->node_info_pool );
1363 0 : if( FD_UNLIKELY( !node_info ) ) {
1364 0 : jsonp_string( peers->http, "info", NULL );
1365 0 : } else {
1366 0 : jsonp_open_object( peers->http, "info" );
1367 0 : jsonp_string( peers->http, "name", node_info->name );
1368 0 : jsonp_string( peers->http, "details", node_info->details );
1369 0 : jsonp_string( peers->http, "website", node_info->website );
1370 0 : jsonp_string( peers->http, "icon_url", node_info->icon_uri );
1371 0 : jsonp_string( peers->http, "keybase_username", node_info->keybase_username );
1372 0 : jsonp_close_object( peers->http );
1373 0 : }
1374 :
1375 0 : jsonp_close_object( peers->http );
1376 0 : }
1377 :
1378 : void
1379 : fd_gui_peers_printf_nodes( fd_gui_peers_ctx_t * peers,
1380 : int * actions,
1381 : ulong * idxs,
1382 0 : ulong count ) {
1383 0 : jsonp_open_envelope( peers->http, "peers", "update" );
1384 0 : jsonp_open_object( peers->http, "value" );
1385 0 : jsonp_open_array( peers->http, "add" );
1386 0 : for( ulong i=0UL; i<count; i++ ) if( FD_UNLIKELY( actions[ i ]==FD_GUI_PEERS_NODE_ADD ) ) peers_printf_node( peers, idxs[ i ] );
1387 0 : jsonp_close_array( peers->http );
1388 :
1389 0 : jsonp_open_array( peers->http, "update" );
1390 0 : for( ulong i=0UL; i<count; i++ ) if( FD_UNLIKELY( actions[ i ]==FD_GUI_PEERS_NODE_UPDATE ) ) peers_printf_node( peers, idxs[ i ] );
1391 0 : jsonp_close_array( peers->http );
1392 :
1393 0 : jsonp_open_array( peers->http, "remove" );
1394 0 : for( ulong i=0UL; i<count; i++ ) {
1395 0 : if( FD_UNLIKELY( actions[ i ]==FD_GUI_PEERS_NODE_DELETE ) ) {
1396 0 : jsonp_open_object( peers->http, NULL );
1397 0 : char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
1398 0 : fd_base58_encode_32( peers->contact_info_table[ idxs[ i ] ].pubkey.uc, NULL, identity_base58 );
1399 0 : jsonp_string( peers->http, "identity_pubkey", identity_base58 );
1400 0 : jsonp_close_object( peers->http );
1401 0 : }
1402 0 : }
1403 0 : jsonp_close_array( peers->http );
1404 0 : jsonp_close_object( peers->http );
1405 0 : jsonp_close_envelope( peers->http );
1406 0 : }
1407 :
1408 : void
1409 0 : fd_gui_peers_printf_node_all( fd_gui_peers_ctx_t * peers ) {
1410 0 : jsonp_open_envelope( peers->http, "peers", "update" );
1411 0 : jsonp_open_object( peers->http, "value" );
1412 0 : jsonp_open_array( peers->http, "add" );
1413 : /* We can iter through the bandwidth tracking table since it will always be populated */
1414 0 : for( fd_gui_peers_bandwidth_tracking_fwd_iter_t iter = fd_gui_peers_bandwidth_tracking_fwd_iter_init( peers->bw_tracking, &FD_GUI_PEERS_BW_TRACKING_INGRESS_SORT_KEY, peers->contact_info_table ), j = 0UL;
1415 0 : !fd_gui_peers_bandwidth_tracking_fwd_iter_done( iter );
1416 0 : iter = fd_gui_peers_bandwidth_tracking_fwd_iter_next( iter, peers->contact_info_table ), j++ ) {
1417 0 : ulong contact_info_table_idx = fd_gui_peers_bandwidth_tracking_fwd_iter_idx( iter );
1418 0 : peers_printf_node( peers, contact_info_table_idx );
1419 0 : }
1420 0 : jsonp_close_array( peers->http );
1421 0 : jsonp_open_array( peers->http, "update" );
1422 0 : jsonp_close_array( peers->http );
1423 0 : jsonp_open_array( peers->http, "remove" );
1424 0 : jsonp_close_array( peers->http );
1425 0 : jsonp_close_object( peers->http );
1426 0 : jsonp_close_envelope( peers->http );
1427 0 : }
1428 :
1429 : void
1430 : fd_gui_printf_peers_gossip_update( fd_gui_t * gui,
1431 : ulong const * updated,
1432 : ulong updated_cnt,
1433 : fd_pubkey_t const * removed,
1434 : ulong removed_cnt,
1435 : ulong const * added,
1436 0 : ulong added_cnt ) {
1437 0 : jsonp_open_envelope( gui->http, "peers", "update" );
1438 0 : jsonp_open_object( gui->http, "value" );
1439 0 : jsonp_open_array( gui->http, "add" );
1440 0 : for( ulong i=0UL; i<added_cnt; i++ ) {
1441 0 : int actually_added = !fd_gui_vote_acct_contains( gui, gui->gossip.peers[ added[ i ] ].pubkey->uc ) &&
1442 0 : !fd_gui_validator_info_contains( gui, gui->gossip.peers[ added[ i ] ].pubkey->uc );
1443 0 : if( FD_LIKELY( !actually_added ) ) continue;
1444 :
1445 0 : fd_gui_printf_peer( gui, gui->gossip.peers[ added[ i ] ].pubkey->uc );
1446 0 : }
1447 0 : jsonp_close_array( gui->http );
1448 :
1449 0 : jsonp_open_array( gui->http, "update" );
1450 0 : for( ulong i=0UL; i<added_cnt; i++ ) {
1451 0 : int actually_added = !fd_gui_vote_acct_contains( gui, gui->gossip.peers[ added[ i ] ].pubkey->uc ) &&
1452 0 : !fd_gui_validator_info_contains( gui, gui->gossip.peers[ added[ i ] ].pubkey->uc );
1453 0 : if( FD_LIKELY( actually_added ) ) continue;
1454 :
1455 0 : fd_gui_printf_peer( gui, gui->gossip.peers[ added[ i ] ].pubkey->uc );
1456 0 : }
1457 0 : for( ulong i=0UL; i<updated_cnt; i++ ) {
1458 0 : fd_gui_printf_peer( gui, gui->gossip.peers[ updated[ i ] ].pubkey->uc );
1459 0 : }
1460 0 : jsonp_close_array( gui->http );
1461 :
1462 0 : jsonp_open_array( gui->http, "remove" );
1463 0 : for( ulong i=0UL; i<removed_cnt; i++ ) {
1464 0 : int actually_removed = !fd_gui_vote_acct_contains( gui, removed[ i ].uc ) &&
1465 0 : !fd_gui_validator_info_contains( gui, removed[ i ].uc );
1466 0 : if( FD_UNLIKELY( !actually_removed ) ) continue;
1467 :
1468 0 : jsonp_open_object( gui->http, NULL );
1469 0 : char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
1470 0 : fd_base58_encode_32( removed[ i ].uc, NULL, identity_base58 );
1471 0 : jsonp_string( gui->http, "identity_pubkey", identity_base58 );
1472 0 : jsonp_close_object( gui->http );
1473 0 : }
1474 0 : jsonp_close_array( gui->http );
1475 0 : jsonp_close_object( gui->http );
1476 0 : jsonp_close_envelope( gui->http );
1477 0 : }
1478 :
1479 : void
1480 : fd_gui_printf_peers_vote_account_update( fd_gui_t * gui,
1481 : ulong const * updated,
1482 : ulong updated_cnt,
1483 : fd_pubkey_t const * removed,
1484 : ulong removed_cnt,
1485 : ulong const * added,
1486 0 : ulong added_cnt ) {
1487 0 : jsonp_open_envelope( gui->http, "peers", "update" );
1488 0 : jsonp_open_object( gui->http, "value" );
1489 0 : jsonp_open_array( gui->http, "add" );
1490 0 : for( ulong i=0UL; i<added_cnt; i++ ) {
1491 0 : int actually_added = !fd_gui_gossip_contains( gui, gui->vote_account.vote_accounts[ added[ i ] ].pubkey->uc ) &&
1492 0 : !fd_gui_validator_info_contains( gui, gui->vote_account.vote_accounts[ added[ i ] ].pubkey->uc );
1493 0 : if( FD_LIKELY( !actually_added ) ) continue;
1494 :
1495 0 : fd_gui_printf_peer( gui, gui->vote_account.vote_accounts[ added[ i ] ].pubkey->uc );
1496 0 : }
1497 0 : jsonp_close_array( gui->http );
1498 :
1499 0 : jsonp_open_array( gui->http, "update" );
1500 0 : for( ulong i=0UL; i<added_cnt; i++ ) {
1501 0 : int actually_added = !fd_gui_gossip_contains( gui, gui->vote_account.vote_accounts[ added[ i ] ].pubkey->uc ) &&
1502 0 : !fd_gui_validator_info_contains( gui, gui->vote_account.vote_accounts[ added[ i ] ].pubkey->uc );
1503 0 : if( FD_LIKELY( actually_added ) ) continue;
1504 :
1505 0 : fd_gui_printf_peer( gui, gui->vote_account.vote_accounts[ added[ i ] ].pubkey->uc );
1506 0 : }
1507 0 : for( ulong i=0UL; i<updated_cnt; i++ ) {
1508 0 : fd_gui_printf_peer( gui, gui->vote_account.vote_accounts[ updated[ i ] ].pubkey->uc );
1509 0 : }
1510 0 : jsonp_close_array( gui->http );
1511 :
1512 0 : jsonp_open_array( gui->http, "remove" );
1513 0 : for( ulong i=0UL; i<removed_cnt; i++ ) {
1514 0 : int actually_removed = !fd_gui_gossip_contains( gui, removed[ i ].uc) &&
1515 0 : !fd_gui_validator_info_contains( gui, removed[ i ].uc);
1516 0 : if( FD_UNLIKELY( !actually_removed ) ) continue;
1517 :
1518 0 : jsonp_open_object( gui->http, NULL );
1519 0 : char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
1520 0 : fd_base58_encode_32( removed[ i ].uc, NULL, identity_base58 );
1521 0 : jsonp_string( gui->http, "identity_pubkey", identity_base58 );
1522 0 : jsonp_close_object( gui->http );
1523 0 : }
1524 0 : jsonp_close_array( gui->http );
1525 0 : jsonp_close_object( gui->http );
1526 0 : jsonp_close_envelope( gui->http );
1527 0 : }
1528 :
1529 : void
1530 : fd_gui_printf_peers_validator_info_update( fd_gui_t * gui,
1531 : ulong const * updated,
1532 : ulong updated_cnt,
1533 : fd_pubkey_t const * removed,
1534 : ulong removed_cnt,
1535 : ulong const * added,
1536 0 : ulong added_cnt ) {
1537 0 : jsonp_open_envelope( gui->http, "peers", "update" );
1538 0 : jsonp_open_object( gui->http, "value" );
1539 0 : jsonp_open_array( gui->http, "add" );
1540 0 : for( ulong i=0UL; i<added_cnt; i++ ) {
1541 0 : int actually_added = !fd_gui_gossip_contains( gui, gui->validator_info.info[ added[ i ] ].pubkey->uc ) &&
1542 0 : !fd_gui_vote_acct_contains( gui, gui->validator_info.info[ added[ i ] ].pubkey->uc );
1543 0 : if( FD_LIKELY( !actually_added ) ) continue;
1544 :
1545 0 : fd_gui_printf_peer( gui, gui->validator_info.info[ added[ i ] ].pubkey->uc );
1546 0 : }
1547 0 : jsonp_close_array( gui->http );
1548 :
1549 0 : jsonp_open_array( gui->http, "update" );
1550 0 : for( ulong i=0UL; i<added_cnt; i++ ) {
1551 0 : int actually_added = !fd_gui_gossip_contains( gui, gui->validator_info.info[ added[ i ] ].pubkey->uc ) &&
1552 0 : !fd_gui_vote_acct_contains( gui, gui->validator_info.info[ added[ i ] ].pubkey->uc );
1553 0 : if( FD_LIKELY( actually_added ) ) continue;
1554 :
1555 0 : fd_gui_printf_peer( gui, gui->validator_info.info[ added[ i ] ].pubkey->uc );
1556 0 : }
1557 0 : for( ulong i=0UL; i<updated_cnt; i++ ) {
1558 0 : fd_gui_printf_peer( gui, gui->validator_info.info[ updated[ i ] ].pubkey->uc );
1559 0 : }
1560 0 : jsonp_close_array( gui->http );
1561 :
1562 0 : jsonp_open_array( gui->http, "remove" );
1563 0 : for( ulong i=0UL; i<removed_cnt; i++ ) {
1564 0 : int actually_removed = !fd_gui_gossip_contains( gui, removed[ i ].uc ) &&
1565 0 : !fd_gui_vote_acct_contains( gui, removed[ i ].uc );
1566 0 : if( FD_UNLIKELY( !actually_removed ) ) continue;
1567 :
1568 0 : jsonp_open_object( gui->http, NULL );
1569 0 : char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
1570 0 : fd_base58_encode_32( removed[ i ].uc, NULL, identity_base58 );
1571 0 : jsonp_string( gui->http, "identity_pubkey", identity_base58 );
1572 0 : jsonp_close_object( gui->http );
1573 0 : }
1574 0 : jsonp_close_array( gui->http );
1575 0 : jsonp_close_object( gui->http );
1576 0 : jsonp_close_envelope( gui->http );
1577 0 : }
1578 :
1579 : void
1580 0 : fd_gui_printf_peers_all( fd_gui_t * gui ) {
1581 0 : jsonp_open_envelope( gui->http, "peers", "update" );
1582 0 : jsonp_open_object( gui->http, "value" );
1583 0 : jsonp_open_array( gui->http, "add" );
1584 0 : for( ulong i=0UL; i<gui->gossip.peer_cnt; i++ ) {
1585 0 : fd_gui_printf_peer( gui, gui->gossip.peers[ i ].pubkey->uc );
1586 0 : }
1587 0 : for( ulong i=0UL; i<gui->vote_account.vote_account_cnt; i++ ) {
1588 0 : int actually_added = !fd_gui_gossip_contains( gui, gui->vote_account.vote_accounts[ i ].pubkey->uc );
1589 0 : if( FD_UNLIKELY( actually_added ) ) {
1590 0 : fd_gui_printf_peer( gui, gui->vote_account.vote_accounts[ i ].pubkey->uc );
1591 0 : }
1592 0 : }
1593 0 : for( ulong i=0UL; i<gui->validator_info.info_cnt; i++ ) {
1594 0 : int actually_added = !fd_gui_gossip_contains( gui, gui->validator_info.info[ i ].pubkey->uc ) &&
1595 0 : !fd_gui_vote_acct_contains( gui, gui->validator_info.info[ i ].pubkey->uc );
1596 0 : if( FD_UNLIKELY( actually_added ) ) {
1597 0 : fd_gui_printf_peer( gui, gui->validator_info.info[ i ].pubkey->uc );
1598 0 : }
1599 0 : }
1600 0 : jsonp_close_array( gui->http );
1601 0 : jsonp_close_object( gui->http );
1602 0 : jsonp_close_envelope( gui->http );
1603 0 : }
1604 :
1605 : static void
1606 : fd_gui_printf_ts_tile_timers( fd_gui_t * gui,
1607 : fd_gui_tile_timers_t const * prev,
1608 0 : fd_gui_tile_timers_t const * cur ) {
1609 0 : jsonp_open_object( gui->http, NULL );
1610 0 : jsonp_ulong_as_str( gui->http, "timestamp_nanos", 0 );
1611 0 : jsonp_open_array( gui->http, "tile_timers" );
1612 0 : fd_gui_printf_tile_timers( gui, prev, cur );
1613 0 : jsonp_close_array( gui->http );
1614 0 : jsonp_close_object( gui->http );
1615 0 : }
1616 :
1617 : void
1618 : fd_gui_printf_slot( fd_gui_t * gui,
1619 0 : ulong _slot ) {
1620 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
1621 :
1622 0 : char const * level;
1623 0 : switch( slot->level ) {
1624 0 : case FD_GUI_SLOT_LEVEL_INCOMPLETE: level = "incomplete"; break;
1625 0 : case FD_GUI_SLOT_LEVEL_COMPLETED: level = "completed"; break;
1626 0 : case FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED: level = "optimistically_confirmed"; break;
1627 0 : case FD_GUI_SLOT_LEVEL_ROOTED: level = "rooted"; break;
1628 0 : case FD_GUI_SLOT_LEVEL_FINALIZED: level = "finalized"; break;
1629 0 : default: level = "unknown"; break;
1630 0 : }
1631 :
1632 0 : fd_gui_slot_t * parent_slot = fd_gui_get_slot( gui, slot->parent_slot );
1633 0 : long duration_nanos = LONG_MAX;
1634 0 : if( FD_LIKELY( slot->completed_time!=LONG_MAX && parent_slot && parent_slot->completed_time!=LONG_MAX ) ) {
1635 0 : duration_nanos = slot->completed_time - parent_slot->completed_time;
1636 0 : }
1637 :
1638 0 : jsonp_open_envelope( gui->http, "slot", "update" );
1639 0 : jsonp_open_object( gui->http, "value" );
1640 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
1641 0 : jsonp_open_object( gui->http, "publish" );
1642 0 : jsonp_ulong( gui->http, "slot", _slot );
1643 0 : jsonp_bool( gui->http, "mine", slot->mine );
1644 0 : if( FD_UNLIKELY( slot->vote_slot!=ULONG_MAX ) ) jsonp_ulong( gui->http, "vote_slot", slot->vote_slot );
1645 0 : else jsonp_null( gui->http, "vote_slot" );
1646 0 : if( FD_UNLIKELY( slot->vote_latency!=UCHAR_MAX ) ) jsonp_ulong( gui->http, "vote_latency", slot->vote_latency );
1647 0 : else jsonp_null( gui->http, "vote_latency" );
1648 :
1649 0 : if( FD_UNLIKELY( lslot && lslot->leader_start_time!=LONG_MAX ) ) jsonp_long_as_str( gui->http, "start_timestamp_nanos", lslot->leader_start_time );
1650 0 : else jsonp_null ( gui->http, "start_timestamp_nanos" );
1651 0 : if( FD_UNLIKELY( lslot && lslot->leader_end_time!=LONG_MAX ) ) jsonp_long_as_str( gui->http, "target_end_timestamp_nanos", lslot->leader_end_time );
1652 0 : else jsonp_null ( gui->http, "target_end_timestamp_nanos" );
1653 :
1654 0 : jsonp_bool( gui->http, "skipped", slot->skipped );
1655 0 : if( FD_UNLIKELY( duration_nanos==LONG_MAX ) ) jsonp_null( gui->http, "duration_nanos" );
1656 0 : else jsonp_long( gui->http, "duration_nanos", duration_nanos );
1657 0 : if( FD_UNLIKELY( slot->completed_time==LONG_MAX ) ) jsonp_null( gui->http, "completed_time_nanos" );
1658 0 : else jsonp_long_as_str( gui->http, "completed_time_nanos", slot->completed_time );
1659 0 : jsonp_string( gui->http, "level", level );
1660 0 : if( FD_UNLIKELY( slot->nonvote_success==UINT_MAX ) ) jsonp_null( gui->http, "success_nonvote_transaction_cnt" );
1661 0 : else jsonp_ulong( gui->http, "success_nonvote_transaction_cnt", slot->nonvote_success );
1662 0 : if( FD_UNLIKELY( slot->nonvote_failed==UINT_MAX ) ) jsonp_null( gui->http, "failed_nonvote_transaction_cnt" );
1663 0 : else jsonp_ulong( gui->http, "failed_nonvote_transaction_cnt", slot->nonvote_failed );
1664 0 : if( FD_UNLIKELY( slot->vote_success==UINT_MAX ) ) jsonp_null( gui->http, "success_vote_transaction_cnt" );
1665 0 : else jsonp_ulong( gui->http, "success_vote_transaction_cnt", slot->vote_success );
1666 0 : if( FD_UNLIKELY( slot->vote_failed==UINT_MAX ) ) jsonp_null( gui->http, "failed_vote_transaction_cnt" );
1667 0 : else jsonp_ulong( gui->http, "failed_vote_transaction_cnt", slot->vote_failed );
1668 0 : if( FD_UNLIKELY( slot->max_compute_units==UINT_MAX ) ) jsonp_null( gui->http, "max_compute_units" );
1669 0 : else jsonp_ulong( gui->http, "max_compute_units", slot->max_compute_units );
1670 0 : if( FD_UNLIKELY( slot->compute_units==UINT_MAX ) ) jsonp_null( gui->http, "compute_units" );
1671 0 : else jsonp_ulong( gui->http, "compute_units", slot->compute_units );
1672 0 : if( FD_UNLIKELY( slot->shred_cnt==UINT_MAX ) ) jsonp_null( gui->http, "shreds" );
1673 0 : else jsonp_ulong( gui->http, "shreds", slot->shred_cnt );
1674 0 : if( FD_UNLIKELY( slot->transaction_fee==ULONG_MAX ) ) jsonp_null( gui->http, "transaction_fee" );
1675 0 : else jsonp_ulong_as_str( gui->http, "transaction_fee", slot->transaction_fee );
1676 0 : if( FD_UNLIKELY( slot->priority_fee==ULONG_MAX ) ) jsonp_null( gui->http, "priority_fee" );
1677 0 : else jsonp_ulong_as_str( gui->http, "priority_fee", slot->priority_fee );
1678 0 : if( FD_UNLIKELY( slot->tips==ULONG_MAX ) ) jsonp_null( gui->http, "tips" );
1679 0 : else jsonp_ulong_as_str( gui->http, "tips", slot->tips );
1680 0 : jsonp_close_object( gui->http );
1681 0 : jsonp_close_object( gui->http );
1682 0 : jsonp_close_envelope( gui->http );
1683 0 : }
1684 :
1685 : void
1686 : fd_gui_printf_summary_ping( fd_gui_t * gui,
1687 0 : ulong id ) {
1688 0 : jsonp_open_envelope( gui->http, "summary", "ping" );
1689 0 : jsonp_ulong( gui->http, "id", id );
1690 0 : jsonp_null( gui->http, "value" );
1691 0 : jsonp_close_envelope( gui->http );
1692 0 : }
1693 :
1694 : void
1695 : fd_gui_printf_slot_rankings_request( fd_gui_t * gui,
1696 : ulong id,
1697 0 : int mine ) {
1698 0 : ulong epoch = ULONG_MAX;
1699 0 : for( ulong i = 0UL; i<2UL; i++ ) {
1700 0 : if( FD_LIKELY( gui->epoch.has_epoch[ i ] ) ) {
1701 : /* the "current" epoch is the smallest */
1702 0 : epoch = fd_ulong_min( epoch, gui->epoch.epochs[ i ].epoch );
1703 0 : }
1704 0 : }
1705 0 : ulong epoch_idx = epoch % 2UL;
1706 :
1707 0 : fd_gui_slot_rankings_t * rankings = fd_ptr_if( mine, (fd_gui_slot_rankings_t *)gui->epoch.epochs[ epoch_idx ].my_rankings, (fd_gui_slot_rankings_t *)gui->epoch.epochs[ epoch_idx ].rankings );
1708 :
1709 0 : jsonp_open_envelope( gui->http, "slot", "query_rankings" );
1710 0 : jsonp_ulong( gui->http, "id", id );
1711 0 : jsonp_open_object( gui->http, "value" );
1712 :
1713 0 : #define OUTPUT_RANKING_ARRAY(field) \
1714 0 : jsonp_open_array( gui->http, "slots_" FD_STRINGIFY(field) ); \
1715 0 : for( ulong i = 0UL; i<fd_ulong_if( epoch==ULONG_MAX, 0UL, FD_GUI_SLOT_RANKINGS_SZ ); i++ ) { \
1716 0 : if( FD_UNLIKELY( rankings->field[ i ].slot==ULONG_MAX ) ) break; \
1717 0 : jsonp_ulong( gui->http, NULL, rankings->field[ i ].slot ); \
1718 0 : } \
1719 0 : jsonp_close_array( gui->http ); \
1720 0 : jsonp_open_array( gui->http, "vals_" FD_STRINGIFY(field) ); \
1721 0 : for( ulong i = 0UL; i<fd_ulong_if( epoch==ULONG_MAX, 0UL, FD_GUI_SLOT_RANKINGS_SZ ); i++ ) { \
1722 0 : if( FD_UNLIKELY( rankings->field[ i ].slot==ULONG_MAX ) ) break; \
1723 0 : jsonp_ulong( gui->http, NULL, rankings->field[ i ].value ); \
1724 0 : } \
1725 0 : jsonp_close_array( gui->http )
1726 :
1727 0 : OUTPUT_RANKING_ARRAY( largest_tips );
1728 0 : OUTPUT_RANKING_ARRAY( largest_fees );
1729 0 : OUTPUT_RANKING_ARRAY( largest_rewards );
1730 0 : OUTPUT_RANKING_ARRAY( largest_rewards_per_cu );
1731 0 : OUTPUT_RANKING_ARRAY( largest_duration );
1732 0 : OUTPUT_RANKING_ARRAY( largest_compute_units );
1733 0 : OUTPUT_RANKING_ARRAY( largest_skipped );
1734 0 : OUTPUT_RANKING_ARRAY( smallest_tips );
1735 0 : OUTPUT_RANKING_ARRAY( smallest_fees );
1736 0 : OUTPUT_RANKING_ARRAY( smallest_rewards );
1737 0 : OUTPUT_RANKING_ARRAY( smallest_rewards_per_cu );
1738 0 : OUTPUT_RANKING_ARRAY( smallest_duration );
1739 0 : OUTPUT_RANKING_ARRAY( smallest_compute_units );
1740 0 : OUTPUT_RANKING_ARRAY( smallest_skipped );
1741 :
1742 0 : #undef OUTPUT_RANKING_ARRAY
1743 :
1744 0 : jsonp_close_object( gui->http );
1745 0 : jsonp_close_envelope( gui->http );
1746 0 : }
1747 :
1748 : void
1749 : fd_gui_printf_slot_request( fd_gui_t * gui,
1750 : ulong _slot,
1751 0 : ulong id ) {
1752 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
1753 :
1754 0 : char const * level;
1755 0 : switch( slot->level ) {
1756 0 : case FD_GUI_SLOT_LEVEL_INCOMPLETE: level = "incomplete"; break;
1757 0 : case FD_GUI_SLOT_LEVEL_COMPLETED: level = "completed"; break;
1758 0 : case FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED: level = "optimistically_confirmed"; break;
1759 0 : case FD_GUI_SLOT_LEVEL_ROOTED: level = "rooted"; break;
1760 0 : case FD_GUI_SLOT_LEVEL_FINALIZED: level = "finalized"; break;
1761 0 : default: level = "unknown"; break;
1762 0 : }
1763 :
1764 0 : fd_gui_slot_t * parent_slot = fd_gui_get_slot( gui, slot->parent_slot );
1765 0 : long duration_nanos = LONG_MAX;
1766 0 : if( FD_LIKELY( slot->completed_time!=LONG_MAX && parent_slot && parent_slot->completed_time!=LONG_MAX ) ) {
1767 0 : duration_nanos = slot->completed_time - parent_slot->completed_time;
1768 0 : }
1769 :
1770 0 : jsonp_open_envelope( gui->http, "slot", "query" );
1771 0 : jsonp_ulong( gui->http, "id", id );
1772 0 : jsonp_open_object( gui->http, "value" );
1773 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
1774 :
1775 0 : jsonp_open_object( gui->http, "publish" );
1776 0 : jsonp_ulong( gui->http, "slot", _slot );
1777 0 : jsonp_bool( gui->http, "mine", slot->mine );
1778 0 : if( FD_UNLIKELY( slot->vote_slot!=ULONG_MAX ) ) jsonp_ulong( gui->http, "vote_slot", slot->vote_slot );
1779 0 : else jsonp_null( gui->http, "vote_slot" );
1780 0 : if( FD_UNLIKELY( slot->vote_latency!=UCHAR_MAX ) ) jsonp_ulong( gui->http, "vote_latency", slot->vote_latency );
1781 0 : else jsonp_null( gui->http, "vote_latency" );
1782 :
1783 0 : if( FD_UNLIKELY( lslot && lslot->leader_start_time!=LONG_MAX ) ) jsonp_long_as_str( gui->http, "start_timestamp_nanos", lslot->leader_start_time );
1784 0 : else jsonp_null ( gui->http, "start_timestamp_nanos" );
1785 0 : if( FD_UNLIKELY( lslot && lslot->leader_end_time!=LONG_MAX ) ) jsonp_long_as_str( gui->http, "target_end_timestamp_nanos", lslot->leader_end_time );
1786 0 : else jsonp_null ( gui->http, "target_end_timestamp_nanos" );
1787 :
1788 0 : jsonp_bool( gui->http, "skipped", slot->skipped );
1789 0 : jsonp_string( gui->http, "level", level );
1790 0 : if( FD_UNLIKELY( duration_nanos==LONG_MAX ) ) jsonp_null( gui->http, "duration_nanos" );
1791 0 : else jsonp_long( gui->http, "duration_nanos", duration_nanos );
1792 0 : if( FD_UNLIKELY( slot->completed_time==LONG_MAX ) ) jsonp_null( gui->http, "completed_time_nanos" );
1793 0 : else jsonp_long_as_str( gui->http, "completed_time_nanos", slot->completed_time );
1794 0 : if( FD_UNLIKELY( slot->nonvote_success==UINT_MAX ) ) jsonp_null( gui->http, "success_nonvote_transaction_cnt" );
1795 0 : else jsonp_ulong( gui->http, "success_nonvote_transaction_cnt", slot->nonvote_success );
1796 0 : if( FD_UNLIKELY( slot->nonvote_failed==UINT_MAX ) ) jsonp_null( gui->http, "failed_nonvote_transaction_cnt" );
1797 0 : else jsonp_ulong( gui->http, "failed_nonvote_transaction_cnt", slot->nonvote_failed );
1798 0 : if( FD_UNLIKELY( slot->vote_success==UINT_MAX ) ) jsonp_null( gui->http, "success_vote_transaction_cnt" );
1799 0 : else jsonp_ulong( gui->http, "success_vote_transaction_cnt", slot->vote_success );
1800 0 : if( FD_UNLIKELY( slot->vote_failed==UINT_MAX ) ) jsonp_null( gui->http, "failed_vote_transaction_cnt" );
1801 0 : else jsonp_ulong( gui->http, "failed_vote_transaction_cnt", slot->vote_failed );
1802 0 : if( FD_UNLIKELY( slot->max_compute_units==UINT_MAX ) ) jsonp_null( gui->http, "max_compute_units" );
1803 0 : else jsonp_ulong( gui->http, "max_compute_units", slot->max_compute_units );
1804 0 : if( FD_UNLIKELY( slot->compute_units==UINT_MAX ) ) jsonp_null( gui->http, "compute_units" );
1805 0 : else jsonp_ulong( gui->http, "compute_units", slot->compute_units );
1806 0 : if( FD_UNLIKELY( slot->shred_cnt==UINT_MAX ) ) jsonp_null( gui->http, "shreds" );
1807 0 : else jsonp_ulong( gui->http, "shreds", slot->shred_cnt );
1808 0 : if( FD_UNLIKELY( slot->transaction_fee==ULONG_MAX ) ) jsonp_null( gui->http, "transaction_fee" );
1809 0 : else jsonp_ulong( gui->http, "transaction_fee", slot->transaction_fee );
1810 0 : if( FD_UNLIKELY( slot->priority_fee==ULONG_MAX ) ) jsonp_null( gui->http, "priority_fee" );
1811 0 : else jsonp_ulong( gui->http, "priority_fee", slot->priority_fee );
1812 0 : if( FD_UNLIKELY( slot->tips==ULONG_MAX ) ) jsonp_null( gui->http, "tips" );
1813 0 : else jsonp_ulong( gui->http, "tips", slot->tips );
1814 0 : jsonp_close_object( gui->http );
1815 :
1816 0 : jsonp_close_object( gui->http );
1817 0 : jsonp_close_envelope( gui->http );
1818 0 : }
1819 :
1820 : void
1821 : fd_gui_printf_slot_transactions_request( fd_gui_t * gui,
1822 : ulong _slot,
1823 0 : ulong id ) {
1824 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
1825 :
1826 0 : char const * level;
1827 0 : switch( slot->level ) {
1828 0 : case FD_GUI_SLOT_LEVEL_INCOMPLETE: level = "incomplete"; break;
1829 0 : case FD_GUI_SLOT_LEVEL_COMPLETED: level = "completed"; break;
1830 0 : case FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED: level = "optimistically_confirmed"; break;
1831 0 : case FD_GUI_SLOT_LEVEL_ROOTED: level = "rooted"; break;
1832 0 : case FD_GUI_SLOT_LEVEL_FINALIZED: level = "finalized"; break;
1833 0 : default: level = "unknown"; break;
1834 0 : }
1835 :
1836 0 : fd_gui_slot_t * parent_slot = fd_gui_get_slot( gui, slot->parent_slot );
1837 0 : long duration_nanos = LONG_MAX;
1838 0 : if( FD_LIKELY( slot->completed_time!=LONG_MAX && parent_slot && parent_slot->completed_time!=LONG_MAX ) ) {
1839 0 : duration_nanos = slot->completed_time - parent_slot->completed_time;
1840 0 : }
1841 :
1842 0 : jsonp_open_envelope( gui->http, "slot", "query_transactions" );
1843 0 : jsonp_ulong( gui->http, "id", id );
1844 0 : jsonp_open_object( gui->http, "value" );
1845 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
1846 :
1847 0 : jsonp_open_object( gui->http, "publish" );
1848 0 : jsonp_ulong( gui->http, "slot", _slot );
1849 0 : jsonp_bool( gui->http, "mine", slot->mine );
1850 0 : if( FD_UNLIKELY( slot->vote_slot!=ULONG_MAX ) ) jsonp_ulong( gui->http, "vote_slot", slot->vote_slot );
1851 0 : else jsonp_null( gui->http, "vote_slot" );
1852 0 : if( FD_UNLIKELY( slot->vote_latency!=UCHAR_MAX ) ) jsonp_ulong( gui->http, "vote_latency", slot->vote_latency );
1853 0 : else jsonp_null( gui->http, "vote_latency" );
1854 :
1855 0 : if( FD_UNLIKELY( lslot && lslot->leader_start_time!=LONG_MAX ) ) jsonp_long_as_str( gui->http, "start_timestamp_nanos", lslot->leader_start_time );
1856 0 : else jsonp_null ( gui->http, "start_timestamp_nanos" );
1857 0 : if( FD_UNLIKELY( lslot && lslot->leader_end_time!=LONG_MAX ) ) jsonp_long_as_str( gui->http, "target_end_timestamp_nanos", lslot->leader_end_time );
1858 0 : else jsonp_null ( gui->http, "target_end_timestamp_nanos" );
1859 :
1860 0 : jsonp_bool( gui->http, "skipped", slot->skipped );
1861 0 : jsonp_string( gui->http, "level", level );
1862 0 : if( FD_UNLIKELY( duration_nanos==LONG_MAX ) ) jsonp_null( gui->http, "duration_nanos" );
1863 0 : else jsonp_long( gui->http, "duration_nanos", duration_nanos );
1864 0 : if( FD_UNLIKELY( slot->completed_time==LONG_MAX ) ) jsonp_null( gui->http, "completed_time_nanos" );
1865 0 : else jsonp_long_as_str( gui->http, "completed_time_nanos", slot->completed_time );
1866 0 : if( FD_UNLIKELY( slot->nonvote_success==UINT_MAX ) ) jsonp_null( gui->http, "success_nonvote_transaction_cnt" );
1867 0 : else jsonp_ulong( gui->http, "success_nonvote_transaction_cnt", slot->nonvote_success );
1868 0 : if( FD_UNLIKELY( slot->nonvote_failed==UINT_MAX ) ) jsonp_null( gui->http, "failed_nonvote_transaction_cnt" );
1869 0 : else jsonp_ulong( gui->http, "failed_nonvote_transaction_cnt", slot->nonvote_failed );
1870 0 : if( FD_UNLIKELY( slot->vote_success==UINT_MAX ) ) jsonp_null( gui->http, "success_vote_transaction_cnt" );
1871 0 : else jsonp_ulong( gui->http, "success_vote_transaction_cnt", slot->vote_success );
1872 0 : if( FD_UNLIKELY( slot->vote_failed==UINT_MAX ) ) jsonp_null( gui->http, "failed_vote_transaction_cnt" );
1873 0 : else jsonp_ulong( gui->http, "failed_vote_transaction_cnt", slot->vote_failed );
1874 0 : if( FD_UNLIKELY( slot->max_compute_units==UINT_MAX ) ) jsonp_null( gui->http, "max_compute_units" );
1875 0 : else jsonp_ulong( gui->http, "max_compute_units", slot->max_compute_units );
1876 0 : if( FD_UNLIKELY( slot->compute_units==UINT_MAX ) ) jsonp_null( gui->http, "compute_units" );
1877 0 : else jsonp_ulong( gui->http, "compute_units", slot->compute_units );
1878 0 : if( FD_UNLIKELY( slot->shred_cnt==UINT_MAX ) ) jsonp_null( gui->http, "shreds" );
1879 0 : else jsonp_ulong( gui->http, "shreds", slot->shred_cnt );
1880 0 : if( FD_UNLIKELY( slot->transaction_fee==ULONG_MAX ) ) jsonp_null( gui->http, "transaction_fee" );
1881 0 : else jsonp_ulong( gui->http, "transaction_fee", slot->transaction_fee );
1882 0 : if( FD_UNLIKELY( slot->priority_fee==ULONG_MAX ) ) jsonp_null( gui->http, "priority_fee" );
1883 0 : else jsonp_ulong( gui->http, "priority_fee", slot->priority_fee );
1884 0 : if( FD_UNLIKELY( slot->tips==ULONG_MAX ) ) jsonp_null( gui->http, "tips" );
1885 0 : else jsonp_ulong( gui->http, "tips", slot->tips );
1886 0 : jsonp_close_object( gui->http );
1887 :
1888 0 : if( FD_UNLIKELY( lslot && lslot->unbecame_leader ) ) {
1889 0 : jsonp_open_object( gui->http, "limits" );
1890 0 : jsonp_ulong( gui->http, "used_total_block_cost", lslot->scheduler_stats->limits_usage->block_cost );
1891 0 : jsonp_ulong( gui->http, "used_total_vote_cost", lslot->scheduler_stats->limits_usage->vote_cost );
1892 0 : jsonp_ulong( gui->http, "used_total_bytes", lslot->scheduler_stats->limits_usage->block_data_bytes );
1893 0 : jsonp_ulong( gui->http, "used_total_microblocks", lslot->scheduler_stats->limits_usage->microblocks );
1894 0 : jsonp_open_array( gui->http, "used_account_write_costs" );
1895 0 : for( ulong i = 0; i<FD_PACK_TOP_WRITERS_CNT; i++ ) {
1896 0 : if( FD_UNLIKELY( !memcmp( lslot->scheduler_stats->limits_usage->top_writers[ i ].key.b, ((fd_pubkey_t){ 0 }).uc, sizeof(fd_pubkey_t) ) ) ) break;
1897 :
1898 0 : jsonp_open_object( gui->http, NULL );
1899 0 : char account_base58[ FD_BASE58_ENCODED_32_SZ ];
1900 0 : fd_base58_encode_32( lslot->scheduler_stats->limits_usage->top_writers[ i ].key.b, NULL, account_base58 );
1901 0 : jsonp_string( gui->http, "account", account_base58 );
1902 0 : jsonp_ulong( gui->http, "cost", lslot->scheduler_stats->limits_usage->top_writers[ i ].total_cost );
1903 0 : jsonp_close_object( gui->http );
1904 0 : }
1905 0 : jsonp_close_array( gui->http );
1906 :
1907 0 : jsonp_ulong( gui->http, "max_total_block_cost", lslot->scheduler_stats->limits->max_cost_per_block );
1908 0 : jsonp_ulong( gui->http, "max_total_vote_cost", lslot->scheduler_stats->limits->max_vote_cost_per_block );
1909 0 : jsonp_ulong( gui->http, "max_account_write_cost", lslot->scheduler_stats->limits->max_write_cost_per_acct );
1910 0 : jsonp_ulong( gui->http, "max_total_bytes", lslot->scheduler_stats->limits->max_data_bytes_per_block );
1911 0 : jsonp_ulong( gui->http, "max_total_microblocks", lslot->scheduler_stats->limits->max_microblocks_per_block );
1912 0 : jsonp_close_object( gui->http );
1913 :
1914 0 : jsonp_open_object( gui->http, "scheduler_stats" );
1915 0 : char block_hash_base58[ FD_BASE58_ENCODED_32_SZ ];
1916 0 : fd_base58_encode_32( lslot->block_hash.uc, NULL, block_hash_base58 );
1917 0 : jsonp_string( gui->http, "block_hash", block_hash_base58 );
1918 :
1919 0 : switch( lslot->scheduler_stats->end_slot_reason ) {
1920 0 : case FD_PACK_END_SLOT_REASON_TIME: {
1921 0 : jsonp_string( gui->http, "end_slot_reason", "timeout" );
1922 0 : break;
1923 0 : }
1924 0 : case FD_PACK_END_SLOT_REASON_MICROBLOCK: {
1925 0 : jsonp_string( gui->http, "end_slot_reason", "microblock_limit" );
1926 0 : break;
1927 0 : }
1928 0 : case FD_PACK_END_SLOT_REASON_LEADER_SWITCH: {
1929 0 : jsonp_string( gui->http, "end_slot_reason", "leader_switch" );
1930 0 : break;
1931 0 : }
1932 0 : default: FD_LOG_ERR(( "unreachable" ));
1933 0 : }
1934 0 : jsonp_open_array( gui->http, "slot_schedule_counts" );
1935 0 : for( ulong i = 0; i<FD_METRICS_COUNTER_PACK_TRANSACTION_SCHEDULE_CNT; i++ ) jsonp_ulong( gui->http, NULL, lslot->scheduler_stats->block_results[ i ] );
1936 0 : jsonp_close_array( gui->http );
1937 0 : jsonp_open_array( gui->http, "end_slot_schedule_counts" );
1938 0 : for( ulong i = 0; i<FD_METRICS_COUNTER_PACK_TRANSACTION_SCHEDULE_CNT; i++ ) jsonp_ulong( gui->http, NULL, lslot->scheduler_stats->end_block_results[ i ] );
1939 0 : jsonp_close_array( gui->http );
1940 :
1941 0 : if( FD_LIKELY( lslot->scheduler_stats->pending_smallest->cus!=ULONG_MAX ) ) jsonp_ulong( gui->http, "pending_smallest_cost", lslot->scheduler_stats->pending_smallest->cus );
1942 0 : else jsonp_null( gui->http, "pending_smallest_cost" );
1943 0 : if( FD_LIKELY( lslot->scheduler_stats->pending_smallest->bytes!=ULONG_MAX ) ) jsonp_ulong( gui->http, "pending_smallest_bytes", lslot->scheduler_stats->pending_smallest->bytes );
1944 0 : else jsonp_null( gui->http, "pending_smallest_bytes" );
1945 0 : if( FD_LIKELY( lslot->scheduler_stats->pending_votes_smallest->cus!=ULONG_MAX ) ) jsonp_ulong( gui->http, "pending_vote_smallest_cost", lslot->scheduler_stats->pending_votes_smallest->cus );
1946 0 : else jsonp_null( gui->http, "pending_vote_smallest_cost" );
1947 0 : if( FD_LIKELY( lslot->scheduler_stats->pending_votes_smallest->bytes!=ULONG_MAX ) ) jsonp_ulong( gui->http, "pending_vote_smallest_bytes", lslot->scheduler_stats->pending_votes_smallest->bytes );
1948 0 : else jsonp_null( gui->http, "pending_vote_smallest_bytes" );
1949 0 : jsonp_close_object( gui->http );
1950 :
1951 0 : } else {
1952 0 : jsonp_null( gui->http, "limits" );
1953 0 : jsonp_null( gui->http, "scheduler_stats" );
1954 0 : }
1955 :
1956 0 : int overwritten = lslot && (gui->pack_txn_idx - lslot->txs.start_offset)>FD_GUI_TXN_HISTORY_SZ;
1957 0 : int processed_all_microblocks = lslot && lslot->unbecame_leader &&
1958 0 : lslot->txs.start_offset!=ULONG_MAX &&
1959 0 : lslot->txs.end_offset!=ULONG_MAX &&
1960 0 : lslot->txs.microblocks_upper_bound!=USHORT_MAX &&
1961 0 : lslot->txs.begin_microblocks==lslot->txs.end_microblocks &&
1962 0 : lslot->txs.begin_microblocks==lslot->txs.microblocks_upper_bound;
1963 :
1964 0 : if( FD_LIKELY( !overwritten && processed_all_microblocks ) ) {
1965 0 : ulong txn_cnt = lslot->txs.end_offset-lslot->txs.start_offset;
1966 :
1967 0 : jsonp_open_object( gui->http, "transactions" );
1968 0 : jsonp_long_as_str( gui->http, "start_timestamp_nanos", lslot->leader_start_time );
1969 0 : jsonp_long_as_str( gui->http, "target_end_timestamp_nanos", lslot->leader_end_time );
1970 0 : jsonp_open_array( gui->http, "txn_mb_start_timestamps_nanos" );
1971 0 : for( ulong i=0UL; i<txn_cnt; i++) jsonp_long_as_str( gui->http, NULL, lslot->leader_start_time + (long)gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->timestamp_delta_start_nanos );
1972 0 : jsonp_close_array( gui->http );
1973 0 : jsonp_open_array( gui->http, "txn_mb_end_timestamps_nanos" );
1974 : /* clamp end_ts to start_ts + 1 */
1975 0 : for( ulong i=0UL; i<txn_cnt; i++) {
1976 0 : jsonp_long_as_str( gui->http, NULL, lslot->leader_start_time + fd_long_max( (long)gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->timestamp_delta_end_nanos,
1977 0 : (long)gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->timestamp_delta_start_nanos + 1L ) );
1978 0 : }
1979 0 : jsonp_close_array( gui->http );
1980 0 : jsonp_open_array( gui->http, "txn_compute_units_requested" );
1981 0 : for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong( gui->http, NULL, gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->compute_units_requested );
1982 0 : jsonp_close_array( gui->http );
1983 0 : jsonp_open_array( gui->http, "txn_compute_units_consumed" );
1984 0 : for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong( gui->http, NULL, gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->compute_units_consumed );
1985 0 : jsonp_close_array( gui->http );
1986 0 : jsonp_open_array( gui->http, "txn_priority_fee" );
1987 0 : for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong_as_str( gui->http, NULL, gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->priority_fee );
1988 0 : jsonp_close_array( gui->http );
1989 0 : jsonp_open_array( gui->http, "txn_transaction_fee" );
1990 0 : for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong_as_str( gui->http, NULL, gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->transaction_fee );
1991 0 : jsonp_close_array( gui->http );
1992 0 : jsonp_open_array( gui->http, "txn_error_code" );
1993 0 : for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong( gui->http, NULL, gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->error_code );
1994 0 : jsonp_close_array( gui->http );
1995 0 : jsonp_open_array( gui->http, "txn_from_bundle" );
1996 0 : for( ulong i=0UL; i<txn_cnt; i++) jsonp_bool( gui->http, NULL, gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->flags & FD_GUI_TXN_FLAGS_FROM_BUNDLE );
1997 0 : jsonp_close_array( gui->http );
1998 0 : jsonp_open_array( gui->http, "txn_is_simple_vote" );
1999 0 : for( ulong i=0UL; i<txn_cnt; i++) jsonp_bool( gui->http, NULL, gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->flags & FD_GUI_TXN_FLAGS_IS_SIMPLE_VOTE );
2000 0 : jsonp_close_array( gui->http );
2001 0 : jsonp_open_array( gui->http, "txn_bank_idx" );
2002 0 : for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong( gui->http, NULL, gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->bank_idx );
2003 0 : jsonp_close_array( gui->http );
2004 0 : jsonp_open_array( gui->http, "txn_preload_end_timestamps_nanos" );
2005 0 : for( ulong i=0UL; i<txn_cnt; i++) {
2006 0 : fd_gui_txn_t * txn = gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ];
2007 0 : long microblock_duration = (long)txn->timestamp_delta_end_nanos - (long)txn->timestamp_delta_start_nanos;
2008 0 : long timestamp_delta_preload_end = (long)txn->timestamp_delta_start_nanos + (long)((double)txn->txn_preload_end_pct * (double)microblock_duration / (double)UCHAR_MAX);
2009 0 : jsonp_long_as_str( gui->http, NULL, lslot->leader_start_time + timestamp_delta_preload_end );
2010 0 : }
2011 0 : jsonp_close_array( gui->http );
2012 0 : jsonp_open_array( gui->http, "txn_start_timestamps_nanos" );
2013 0 : for( ulong i=0UL; i<txn_cnt; i++) {
2014 0 : fd_gui_txn_t * txn = gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ];
2015 0 : long microblock_duration = (long)txn->timestamp_delta_end_nanos - (long)txn->timestamp_delta_start_nanos;
2016 0 : long timestamp_delta_validate_end = (long)txn->timestamp_delta_start_nanos + (long)((double)txn->txn_start_pct * (double)microblock_duration / (double)UCHAR_MAX);
2017 0 : jsonp_long_as_str( gui->http, NULL, lslot->leader_start_time + timestamp_delta_validate_end );
2018 0 : }
2019 0 : jsonp_close_array( gui->http );
2020 0 : jsonp_open_array( gui->http, "txn_load_end_timestamps_nanos" );
2021 0 : for( ulong i=0UL; i<txn_cnt; i++) {
2022 0 : fd_gui_txn_t * txn = gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ];
2023 0 : long microblock_duration = (long)txn->timestamp_delta_end_nanos - (long)txn->timestamp_delta_start_nanos;
2024 0 : long timestamp_delta_load_end = (long)txn->timestamp_delta_start_nanos + (long)((double)txn->txn_load_end_pct * (double)microblock_duration / (double)UCHAR_MAX);
2025 0 : jsonp_long_as_str( gui->http, NULL, lslot->leader_start_time + timestamp_delta_load_end );
2026 0 : }
2027 0 : jsonp_close_array( gui->http );
2028 0 : jsonp_open_array( gui->http, "txn_end_timestamps_nanos" );
2029 0 : for( ulong i=0UL; i<txn_cnt; i++) {
2030 0 : fd_gui_txn_t * txn = gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ];
2031 0 : long microblock_duration = (long)txn->timestamp_delta_end_nanos - (long)txn->timestamp_delta_start_nanos;
2032 0 : long timestamp_delta_exec_end = (long)txn->timestamp_delta_start_nanos + (long)((double)txn->txn_end_pct * (double)microblock_duration / (double)UCHAR_MAX);
2033 0 : jsonp_long_as_str( gui->http, NULL, lslot->leader_start_time + timestamp_delta_exec_end );
2034 0 : }
2035 0 : jsonp_close_array( gui->http );
2036 0 : jsonp_open_array( gui->http, "txn_arrival_timestamps_nanos" );
2037 0 : for( ulong i=0UL; i<txn_cnt; i++) jsonp_long_as_str( gui->http, NULL, gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->timestamp_arrival_nanos );
2038 0 : jsonp_close_array( gui->http );
2039 0 : jsonp_open_array( gui->http, "txn_tips" );
2040 0 : for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong_as_str( gui->http, NULL, gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->tips );
2041 0 : jsonp_close_array( gui->http );
2042 0 : jsonp_open_array( gui->http, "txn_source_ipv4" );
2043 0 : for( ulong i=0UL; i<txn_cnt; i++) {
2044 0 : char addr[ 64 ];
2045 0 : fd_cstr_printf_check( addr, sizeof(addr), NULL, FD_IP4_ADDR_FMT, FD_IP4_ADDR_FMT_ARGS( gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->source_ipv4 ) );
2046 0 : jsonp_string( gui->http, NULL, addr );
2047 0 : }
2048 0 : jsonp_close_array( gui->http );
2049 0 : jsonp_open_array( gui->http, "txn_source_tpu" );
2050 0 : for( ulong i=0UL; i<txn_cnt; i++) {
2051 0 : switch ( gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->source_tpu ) {
2052 0 : case FD_TXN_M_TPU_SOURCE_QUIC: {
2053 0 : jsonp_string( gui->http, NULL, "quic");
2054 0 : break;
2055 0 : }
2056 0 : case FD_TXN_M_TPU_SOURCE_UDP : {
2057 0 : jsonp_string( gui->http, NULL, "udp");
2058 0 : break;
2059 0 : }
2060 0 : case FD_TXN_M_TPU_SOURCE_GOSSIP: {
2061 0 : jsonp_string( gui->http, NULL, "gossip");
2062 0 : break;
2063 0 : }
2064 0 : case FD_TXN_M_TPU_SOURCE_BUNDLE: {
2065 0 : jsonp_string( gui->http, NULL, "bundle");
2066 0 : break;
2067 0 : }
2068 0 : case FD_TXN_M_TPU_SOURCE_TXSEND: {
2069 0 : jsonp_string( gui->http, NULL, "send");
2070 0 : break;
2071 0 : }
2072 0 : default: FD_LOG_ERR(("unknown tpu"));
2073 0 : }
2074 0 : }
2075 0 : jsonp_close_array( gui->http );
2076 0 : jsonp_open_array( gui->http, "txn_microblock_id" );
2077 0 : for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong( gui->http, NULL, gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->microblock_idx );
2078 0 : jsonp_close_array( gui->http );
2079 0 : jsonp_open_array( gui->http, "txn_landed" );
2080 0 : for( ulong i=0UL; i<txn_cnt; i++) jsonp_bool( gui->http, NULL, gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->flags & FD_GUI_TXN_FLAGS_LANDED_IN_BLOCK );
2081 0 : jsonp_close_array( gui->http );
2082 0 : jsonp_open_array( gui->http, "txn_signature" );
2083 0 : for( ulong i=0UL; i<txn_cnt; i++) {
2084 0 : FD_BASE58_ENCODE_64_BYTES( gui->txs[ (lslot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->signature, encoded_signature );
2085 0 : jsonp_string( gui->http, NULL, encoded_signature );
2086 0 : }
2087 0 : jsonp_close_array( gui->http );
2088 0 : jsonp_close_object( gui->http );
2089 0 : } else {
2090 0 : jsonp_null( gui->http, "transactions" );
2091 0 : }
2092 :
2093 0 : jsonp_close_object( gui->http );
2094 0 : jsonp_close_envelope( gui->http );
2095 0 : }
2096 :
2097 : void
2098 : fd_gui_printf_slot_request_detailed( fd_gui_t * gui,
2099 : ulong _slot,
2100 0 : ulong id ) {
2101 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
2102 :
2103 0 : char const * level;
2104 0 : switch( slot->level ) {
2105 0 : case FD_GUI_SLOT_LEVEL_INCOMPLETE: level = "incomplete"; break;
2106 0 : case FD_GUI_SLOT_LEVEL_COMPLETED: level = "completed"; break;
2107 0 : case FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED: level = "optimistically_confirmed"; break;
2108 0 : case FD_GUI_SLOT_LEVEL_ROOTED: level = "rooted"; break;
2109 0 : case FD_GUI_SLOT_LEVEL_FINALIZED: level = "finalized"; break;
2110 0 : default: level = "unknown"; break;
2111 0 : }
2112 :
2113 0 : fd_gui_slot_t * parent_slot = fd_gui_get_slot( gui, slot->parent_slot );
2114 0 : long duration_nanos = LONG_MAX;
2115 0 : if( FD_LIKELY( slot->completed_time!=LONG_MAX && parent_slot && parent_slot->completed_time!=LONG_MAX ) ) {
2116 0 : duration_nanos = slot->completed_time - parent_slot->completed_time;
2117 0 : }
2118 :
2119 0 : jsonp_open_envelope( gui->http, "slot", "query_detailed" );
2120 0 : jsonp_ulong( gui->http, "id", id );
2121 0 : jsonp_open_object( gui->http, "value" );
2122 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
2123 :
2124 0 : jsonp_open_object( gui->http, "publish" );
2125 0 : jsonp_ulong( gui->http, "slot", _slot );
2126 0 : jsonp_bool( gui->http, "mine", slot->mine );
2127 0 : if( FD_UNLIKELY( slot->vote_slot!=ULONG_MAX ) ) jsonp_ulong( gui->http, "vote_slot", slot->vote_slot );
2128 0 : else jsonp_null( gui->http, "vote_slot" );
2129 0 : if( FD_UNLIKELY( slot->vote_latency!=UCHAR_MAX ) ) jsonp_ulong( gui->http, "vote_latency", slot->vote_latency );
2130 0 : else jsonp_null( gui->http, "vote_latency" );
2131 :
2132 0 : if( FD_UNLIKELY( lslot && lslot->leader_start_time!=LONG_MAX ) ) jsonp_long_as_str( gui->http, "start_timestamp_nanos", lslot->leader_start_time );
2133 0 : else jsonp_null ( gui->http, "start_timestamp_nanos" );
2134 0 : if( FD_UNLIKELY( lslot && lslot->leader_end_time!=LONG_MAX ) ) jsonp_long_as_str( gui->http, "target_end_timestamp_nanos", lslot->leader_end_time );
2135 0 : else jsonp_null ( gui->http, "target_end_timestamp_nanos" );
2136 :
2137 0 : jsonp_bool( gui->http, "skipped", slot->skipped );
2138 0 : jsonp_string( gui->http, "level", level );
2139 0 : if( FD_UNLIKELY( duration_nanos==LONG_MAX ) ) jsonp_null( gui->http, "duration_nanos" );
2140 0 : else jsonp_long( gui->http, "duration_nanos", duration_nanos );
2141 0 : if( FD_UNLIKELY( slot->completed_time==LONG_MAX ) ) jsonp_null( gui->http, "completed_time_nanos" );
2142 0 : else jsonp_long_as_str( gui->http, "completed_time_nanos", slot->completed_time );
2143 0 : if( FD_UNLIKELY( slot->nonvote_success==UINT_MAX ) ) jsonp_null( gui->http, "success_nonvote_transaction_cnt" );
2144 0 : else jsonp_ulong( gui->http, "success_nonvote_transaction_cnt", slot->nonvote_success );
2145 0 : if( FD_UNLIKELY( slot->nonvote_failed==UINT_MAX ) ) jsonp_null( gui->http, "failed_nonvote_transaction_cnt" );
2146 0 : else jsonp_ulong( gui->http, "failed_nonvote_transaction_cnt", slot->nonvote_failed );
2147 0 : if( FD_UNLIKELY( slot->vote_success==UINT_MAX ) ) jsonp_null( gui->http, "success_vote_transaction_cnt" );
2148 0 : else jsonp_ulong( gui->http, "success_vote_transaction_cnt", slot->vote_success );
2149 0 : if( FD_UNLIKELY( slot->vote_failed==UINT_MAX ) ) jsonp_null( gui->http, "failed_vote_transaction_cnt" );
2150 0 : else jsonp_ulong( gui->http, "failed_vote_transaction_cnt", slot->vote_failed );
2151 0 : if( FD_UNLIKELY( slot->max_compute_units==UINT_MAX ) ) jsonp_null( gui->http, "max_compute_units" );
2152 0 : else jsonp_ulong( gui->http, "max_compute_units", slot->max_compute_units );
2153 0 : if( FD_UNLIKELY( slot->compute_units==UINT_MAX ) ) jsonp_null( gui->http, "compute_units" );
2154 0 : else jsonp_ulong( gui->http, "compute_units", slot->compute_units );
2155 0 : if( FD_UNLIKELY( slot->shred_cnt==UINT_MAX ) ) jsonp_null( gui->http, "shreds" );
2156 0 : else jsonp_ulong( gui->http, "shreds", slot->shred_cnt );
2157 0 : if( FD_UNLIKELY( slot->transaction_fee==ULONG_MAX ) ) jsonp_null( gui->http, "transaction_fee" );
2158 0 : else jsonp_ulong( gui->http, "transaction_fee", slot->transaction_fee );
2159 0 : if( FD_UNLIKELY( slot->priority_fee==ULONG_MAX ) ) jsonp_null( gui->http, "priority_fee" );
2160 0 : else jsonp_ulong( gui->http, "priority_fee", slot->priority_fee );
2161 0 : if( FD_UNLIKELY( slot->tips==ULONG_MAX ) ) jsonp_null( gui->http, "tips" );
2162 0 : else jsonp_ulong( gui->http, "tips", slot->tips );
2163 0 : jsonp_close_object( gui->http );
2164 :
2165 0 : if( FD_LIKELY( gui->summary.slot_completed!=ULONG_MAX && gui->summary.slot_completed>_slot ) ) {
2166 0 : fd_gui_printf_waterfall( gui, slot->waterfall_begin, slot->waterfall_end );
2167 :
2168 0 : fd_gui_leader_slot_t * lslot = fd_gui_get_leader_slot( gui, _slot );
2169 0 : if( FD_LIKELY( lslot && lslot->unbecame_leader ) ) {
2170 0 : jsonp_open_array( gui->http, "tile_timers" );
2171 0 : fd_gui_tile_timers_t const * prev_timer = lslot->tile_timers;
2172 0 : for( ulong i=1UL; i<lslot->tile_timers_sample_cnt; i++ ) {
2173 0 : fd_gui_tile_timers_t const * cur_timer = lslot->tile_timers + i * gui->tile_cnt;
2174 0 : fd_gui_printf_ts_tile_timers( gui, prev_timer, cur_timer );
2175 0 : prev_timer = cur_timer;
2176 0 : }
2177 0 : jsonp_close_array( gui->http );
2178 0 : } else {
2179 : /* Our tile timers were overwritten. */
2180 0 : jsonp_null( gui->http, "tile_timers" );
2181 0 : }
2182 :
2183 0 : if( FD_LIKELY( lslot && lslot->unbecame_leader ) ) {
2184 0 : jsonp_open_array( gui->http, "scheduler_counts" );
2185 : /* Unlike tile timers (which are counters), scheduler counts
2186 : are a gauge and we don't take a diff. */
2187 0 : for( ulong i=0UL; i<lslot->scheduler_counts_sample_cnt; i++ ) {
2188 0 : fd_gui_scheduler_counts_t const * cur = lslot->scheduler_counts[ i ];
2189 0 : jsonp_open_object( gui->http, NULL );
2190 0 : jsonp_long_as_str( gui->http, "timestamp_nanos", cur->sample_time_ns );
2191 0 : jsonp_ulong ( gui->http, "regular", cur->regular );
2192 0 : jsonp_ulong ( gui->http, "votes", cur->votes );
2193 0 : jsonp_ulong ( gui->http, "conflicting", cur->conflicting );
2194 0 : jsonp_ulong ( gui->http, "bundles", cur->bundles );
2195 0 : jsonp_close_object( gui->http );
2196 0 : }
2197 0 : jsonp_close_array( gui->http );
2198 0 : } else {
2199 : /* Our scheduler counts were overwritten. */
2200 0 : jsonp_null( gui->http, "scheduler_counts" );
2201 0 : }
2202 :
2203 0 : fd_gui_printf_tile_stats( gui, slot->tile_stats_begin, slot->tile_stats_end );
2204 0 : } else {
2205 0 : jsonp_null( gui->http, "waterfall" );
2206 0 : jsonp_null( gui->http, "tile_timers" );
2207 0 : jsonp_null( gui->http, "tile_primary_metric" );
2208 0 : }
2209 :
2210 0 : jsonp_close_object( gui->http );
2211 0 : jsonp_close_envelope( gui->http );
2212 0 : }
2213 :
2214 : void
2215 0 : fd_gui_printf_boot_progress( fd_gui_t * gui ) {
2216 0 : jsonp_open_envelope( gui->http, "summary", "boot_progress" );
2217 0 : jsonp_open_object( gui->http, "value" );
2218 0 : switch( gui->summary.boot_progress.phase ) {
2219 0 : case FD_GUI_BOOT_PROGRESS_TYPE_JOINING_GOSSIP: jsonp_string( gui->http, "phase", "joining_gossip" ); break;
2220 0 : case FD_GUI_BOOT_PROGRESS_TYPE_LOADING_FULL_SNAPSHOT: jsonp_string( gui->http, "phase", "loading_full_snapshot" ); break;
2221 0 : case FD_GUI_BOOT_PROGRESS_TYPE_LOADING_INCREMENTAL_SNAPSHOT: jsonp_string( gui->http, "phase", "loading_incremental_snapshot" ); break;
2222 0 : case FD_GUI_BOOT_PROGRESS_TYPE_WAITING_FOR_SUPERMAJORITY: jsonp_string( gui->http, "phase", "waiting_for_supermajority" ); break;
2223 0 : case FD_GUI_BOOT_PROGRESS_TYPE_CATCHING_UP: jsonp_string( gui->http, "phase", "catching_up" ); break;
2224 0 : case FD_GUI_BOOT_PROGRESS_TYPE_RUNNING: jsonp_string( gui->http, "phase", "running" ); break;
2225 0 : default: FD_LOG_ERR(( "unknown phase %d", gui->summary.boot_progress.phase ));
2226 0 : }
2227 :
2228 0 : jsonp_double( gui->http, "joining_gossip_elapsed_seconds", (double)(gui->summary.boot_progress.joining_gossip_time_nanos - gui->summary.startup_time_nanos) / 1e9 );
2229 :
2230 0 : #define HANDLE_SNAPSHOT_STATE(snapshot_type, snapshot_type_upper) { \
2231 0 : ulong snapshot_idx = FD_GUI_BOOT_PROGRESS_##snapshot_type_upper##_SNAPSHOT_IDX; \
2232 0 : if( FD_LIKELY( gui->summary.boot_progress.phase>=FD_GUI_BOOT_PROGRESS_TYPE_LOADING_##snapshot_type_upper##_SNAPSHOT && gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].slot!=ULONG_MAX )) { \
2233 0 : jsonp_double ( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_elapsed_seconds", (double)(gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].sample_time_nanos - gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].reset_time_nanos) / 1e9 ); \
2234 0 : jsonp_ulong ( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_reset_count", gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].reset_cnt ); \
2235 0 : jsonp_ulong ( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_slot", gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].slot ); \
2236 0 : jsonp_ulong_as_str( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_total_bytes_compressed", gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].total_bytes_compressed ); \
2237 0 : jsonp_ulong_as_str( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_read_bytes_compressed", gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].read_bytes_compressed ); \
2238 0 : jsonp_string ( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_read_path", gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].read_path ); \
2239 0 : jsonp_ulong_as_str( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_decompress_bytes_decompressed", gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].decompress_bytes_decompressed ); \
2240 0 : jsonp_ulong_as_str( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_decompress_bytes_compressed", gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].decompress_bytes_compressed ); \
2241 0 : jsonp_ulong_as_str( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_insert_bytes_decompressed", gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].insert_bytes_decompressed ); \
2242 0 : jsonp_ulong ( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_insert_accounts", gui->summary.boot_progress.loading_snapshot[ snapshot_idx ].insert_accounts_current ); \
2243 0 : } else { \
2244 0 : jsonp_null( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_elapsed_seconds" ); \
2245 0 : jsonp_null( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_reset_count" ); \
2246 0 : jsonp_null( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_slot" ); \
2247 0 : jsonp_null( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_total_bytes_compressed" ); \
2248 0 : jsonp_null( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_read_bytes_compressed" ); \
2249 0 : jsonp_null( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_read_path" ); \
2250 0 : jsonp_null( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_decompress_bytes_decompressed" ); \
2251 0 : jsonp_null( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_decompress_bytes_compressed" ); \
2252 0 : jsonp_null( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_insert_bytes_decompressed" ); \
2253 0 : jsonp_null( gui->http, "loading_" FD_STRINGIFY(snapshot_type) "_snapshot_insert_accounts" ); \
2254 0 : } \
2255 0 : }
2256 :
2257 0 : HANDLE_SNAPSHOT_STATE(full, FULL)
2258 0 : HANDLE_SNAPSHOT_STATE(incremental, INCREMENTAL)
2259 0 : #undef HANDLE_SNAPSHOT_STATE
2260 :
2261 0 : if( FD_LIKELY( gui->summary.wfs_enabled ) ) {
2262 0 : jsonp_string ( gui->http, "wait_for_supermajority_bank_hash", gui->summary.wfs_bank_hash );
2263 0 : char shred_version_str[ 8 ];
2264 0 : FD_TEST( fd_cstr_printf_check( shred_version_str, sizeof(shred_version_str), NULL, "%hu", gui->summary.expected_shred_version ) );
2265 0 : jsonp_string ( gui->http, "wait_for_supermajority_shred_version", shred_version_str );
2266 0 : if( FD_LIKELY( gui->summary.boot_progress.phase>=FD_GUI_BOOT_PROGRESS_TYPE_WAITING_FOR_SUPERMAJORITY ) ) {
2267 0 : jsonp_ulong ( gui->http, "wait_for_supermajority_attempt", gui->summary.boot_progress.wfs_attempt );
2268 0 : jsonp_ulong_as_str( gui->http, "wait_for_supermajority_total_stake", gui->summary.boot_progress.wfs_total_stake );
2269 0 : jsonp_ulong_as_str( gui->http, "wait_for_supermajority_connected_stake", gui->summary.boot_progress.wfs_connected_stake );
2270 0 : jsonp_ulong ( gui->http, "wait_for_supermajority_total_peers", gui->summary.boot_progress.wfs_total_peers );
2271 0 : jsonp_ulong ( gui->http, "wait_for_supermajority_connected_peers", gui->summary.boot_progress.wfs_connected_peers );
2272 0 : } else {
2273 0 : jsonp_null( gui->http, "wait_for_supermajority_attempt" );
2274 0 : jsonp_null( gui->http, "wait_for_supermajority_total_stake" );
2275 0 : jsonp_null( gui->http, "wait_for_supermajority_connected_stake" );
2276 0 : jsonp_null( gui->http, "wait_for_supermajority_total_peers" );
2277 0 : jsonp_null( gui->http, "wait_for_supermajority_connected_peers" );
2278 0 : }
2279 0 : } else {
2280 0 : jsonp_null( gui->http, "wait_for_supermajority_bank_hash" );
2281 0 : jsonp_null( gui->http, "wait_for_supermajority_shred_version" );
2282 0 : jsonp_null( gui->http, "wait_for_supermajority_attempt" );
2283 0 : jsonp_null( gui->http, "wait_for_supermajority_total_stake" );
2284 0 : jsonp_null( gui->http, "wait_for_supermajority_connected_stake" );
2285 0 : jsonp_null( gui->http, "wait_for_supermajority_total_peers" );
2286 0 : jsonp_null( gui->http, "wait_for_supermajority_connected_peers" );
2287 0 : }
2288 :
2289 0 : if( FD_LIKELY( gui->summary.boot_progress.phase>=FD_GUI_BOOT_PROGRESS_TYPE_CATCHING_UP ) ) jsonp_double( gui->http, "catching_up_elapsed_seconds", (double)(gui->summary.boot_progress.catching_up_time_nanos - gui->summary.boot_progress.loading_snapshot[ FD_GUI_BOOT_PROGRESS_INCREMENTAL_SNAPSHOT_IDX ].sample_time_nanos) / 1e9 );
2290 0 : else jsonp_null ( gui->http, "catching_up_elapsed_seconds" );
2291 :
2292 0 : if( FD_LIKELY( gui->summary.boot_progress.phase>=FD_GUI_BOOT_PROGRESS_TYPE_CATCHING_UP
2293 0 : && gui->summary.boot_progress.catching_up_first_replay_slot!=ULONG_MAX ) ) {
2294 0 : jsonp_ulong( gui->http, "catching_up_first_replay_slot", gui->summary.boot_progress.catching_up_first_replay_slot );
2295 0 : } else {
2296 0 : jsonp_null( gui->http, "catching_up_first_replay_slot" );
2297 0 : }
2298 :
2299 0 : jsonp_close_object( gui->http );
2300 0 : jsonp_close_envelope( gui->http );
2301 0 : }
2302 :
2303 : void
2304 : fd_gui_printf_peers_viewport_update( fd_gui_peers_ctx_t * peers,
2305 0 : ulong ws_conn_id ) {
2306 0 : jsonp_open_envelope( peers->http, "gossip", "view_update" );
2307 0 : jsonp_open_object( peers->http, "value" );
2308 0 : jsonp_open_array( peers->http, "changes" );
2309 :
2310 : /* loop over latest viewport */
2311 0 : FD_TEST( peers->client_viewports[ ws_conn_id ].connected );
2312 0 : if( FD_UNLIKELY( peers->client_viewports[ ws_conn_id ].row_cnt>FD_GUI_PEERS_WS_VIEWPORT_MAX_SZ ) ) FD_LOG_ERR(("row_cnt=%lu ws_conn_id=%lu peers->active_ws_conn_id=%lu", peers->client_viewports[ ws_conn_id ].row_cnt, ws_conn_id, peers->active_ws_conn_id ));
2313 :
2314 0 : for( fd_gui_peers_live_table_fwd_iter_t iter = fd_gui_peers_live_table_fwd_iter_init( peers->live_table, &peers->client_viewports[ ws_conn_id ].sort_key, peers->contact_info_table ), j = 0;
2315 0 : !fd_gui_peers_live_table_fwd_iter_done( iter ) && j<peers->client_viewports[ ws_conn_id ].start_row+peers->client_viewports[ ws_conn_id ].row_cnt;
2316 0 : iter = fd_gui_peers_live_table_fwd_iter_next( iter, peers->contact_info_table ), j++ ) {
2317 0 : if( FD_LIKELY( j<peers->client_viewports[ ws_conn_id ].start_row ) ) continue;
2318 0 : fd_gui_peers_node_t const * cur = fd_gui_peers_live_table_fwd_iter_ele_const( iter, peers->contact_info_table );
2319 0 : fd_gui_peers_node_t * ref = &peers->client_viewports[ ws_conn_id ].viewport[ j-peers->client_viewports[ ws_conn_id ].start_row ];
2320 :
2321 : /* This code should be kept in sync with updates to
2322 : fd_gui_peers_live_table */
2323 0 : if( FD_UNLIKELY( cur->stake!=ref->stake ) ) {
2324 0 : jsonp_open_object( peers->http, NULL );
2325 0 : jsonp_ulong ( peers->http, "row_index", j );
2326 0 : jsonp_string( peers->http, "column_name", "Stake" );
2327 :
2328 0 : if( FD_UNLIKELY( cur->stake==ULONG_MAX ) ) jsonp_long ( peers->http, "new_value", -1 );
2329 0 : else jsonp_ulong( peers->http, "new_value", cur->stake );
2330 0 : jsonp_close_object( peers->http );
2331 0 : }
2332 :
2333 0 : if( FD_UNLIKELY( strncmp( cur->name, ref->name, sizeof(ref->name) ) ) ) {
2334 0 : jsonp_open_object( peers->http, NULL );
2335 0 : jsonp_ulong ( peers->http, "row_index", j );
2336 0 : jsonp_string( peers->http, "column_name", "Name" );
2337 0 : jsonp_string( peers->http, "new_value", cur->name );
2338 0 : jsonp_close_object( peers->http );
2339 0 : }
2340 :
2341 0 : if( FD_UNLIKELY( cur->country_code_idx!=ref->country_code_idx ) ) {
2342 0 : jsonp_open_object( peers->http, NULL );
2343 0 : jsonp_ulong ( peers->http, "row_index", j );
2344 0 : jsonp_string( peers->http, "column_name", "Country" );
2345 0 : jsonp_string( peers->http, "new_value", peers->dbip.country_code[ cur->country_code_idx ] );
2346 0 : jsonp_close_object( peers->http );
2347 0 : }
2348 :
2349 0 : if( FD_UNLIKELY( memcmp( cur->pubkey.uc, ref->pubkey.uc, 32UL ) ) ) {
2350 0 : jsonp_open_object( peers->http, NULL );
2351 0 : jsonp_ulong ( peers->http, "row_index", j );
2352 0 : jsonp_string( peers->http, "column_name", "Pubkey" );
2353 :
2354 0 : char pubkey_base58[ FD_BASE58_ENCODED_32_SZ ];
2355 0 : fd_base58_encode_32( cur->pubkey.uc, NULL, pubkey_base58 );
2356 0 : jsonp_string( peers->http, "new_value", pubkey_base58 );
2357 0 : jsonp_close_object( peers->http );
2358 0 : }
2359 :
2360 0 : uint ip4_after = cur->contact_info.sockets[ FD_GOSSIP_CONTACT_INFO_SOCKET_GOSSIP ].is_ipv6 ? 0U : cur->contact_info.sockets[ FD_GOSSIP_CONTACT_INFO_SOCKET_GOSSIP ].ip4;
2361 0 : uint ip4_before = ref->contact_info.sockets[ FD_GOSSIP_CONTACT_INFO_SOCKET_GOSSIP ].is_ipv6 ? 0U : ref->contact_info.sockets[ FD_GOSSIP_CONTACT_INFO_SOCKET_GOSSIP ].ip4;
2362 0 : if( FD_UNLIKELY( ip4_after!=ip4_before ) ) {
2363 0 : jsonp_open_object( peers->http, NULL );
2364 0 : jsonp_ulong ( peers->http, "row_index", j );
2365 0 : jsonp_string( peers->http, "column_name", "IP Addr" );
2366 :
2367 0 : char peer_addr[ 16 ]; /* 255.255.255.255 + '\0' */
2368 0 : FD_TEST( fd_cstr_printf_check( peer_addr, sizeof(peer_addr), NULL, FD_IP4_ADDR_FMT, FD_IP4_ADDR_FMT_ARGS( ip4_after ) ) );
2369 0 : jsonp_string( peers->http, "new_value", peer_addr );
2370 0 : jsonp_close_object( peers->http );
2371 0 : }
2372 :
2373 0 : long cur_egress_push_kbps = cur->gossip_tx[ FD_METRICS_ENUM_GOSSIP_MESSAGE_V_PUSH_IDX ].rate_ema;
2374 0 : long ref_egress_push_kbps = ref->gossip_tx[ FD_METRICS_ENUM_GOSSIP_MESSAGE_V_PUSH_IDX ].rate_ema;
2375 0 : long cur_ingress_push_kbps = cur->gossvf_rx[ FD_METRICS_ENUM_GOSSIP_MESSAGE_V_PUSH_IDX ].rate_ema;
2376 0 : long ref_ingress_push_kbps = ref->gossvf_rx[ FD_METRICS_ENUM_GOSSIP_MESSAGE_V_PUSH_IDX ].rate_ema;
2377 0 : long cur_egress_pull_response_kbps = cur->gossip_tx[ FD_METRICS_ENUM_GOSSIP_MESSAGE_V_PULL_RESPONSE_IDX ].rate_ema;
2378 0 : long ref_egress_pull_response_kbps = ref->gossip_tx[ FD_METRICS_ENUM_GOSSIP_MESSAGE_V_PULL_RESPONSE_IDX ].rate_ema;
2379 0 : long cur_ingress_pull_response_kbps = cur->gossvf_rx[ FD_METRICS_ENUM_GOSSIP_MESSAGE_V_PULL_RESPONSE_IDX ].rate_ema;
2380 0 : long ref_ingress_pull_response_kbps = ref->gossvf_rx[ FD_METRICS_ENUM_GOSSIP_MESSAGE_V_PULL_RESPONSE_IDX ].rate_ema;
2381 :
2382 0 : if( FD_UNLIKELY( ref->valid && cur_ingress_pull_response_kbps!=ref_ingress_pull_response_kbps ) ) {
2383 0 : jsonp_open_object( peers->http, NULL );
2384 0 : jsonp_ulong ( peers->http, "row_index", j );
2385 0 : jsonp_string( peers->http, "column_name", "Ingress Pull" );
2386 0 : jsonp_long ( peers->http, "new_value", cur_ingress_pull_response_kbps );
2387 0 : jsonp_close_object( peers->http );
2388 0 : }
2389 :
2390 0 : if( FD_UNLIKELY( ref->valid && cur_ingress_push_kbps!=ref_ingress_push_kbps ) ) {
2391 0 : jsonp_open_object( peers->http, NULL );
2392 0 : jsonp_ulong ( peers->http, "row_index", j );
2393 0 : jsonp_string( peers->http, "column_name", "Ingress Push" );
2394 0 : jsonp_long ( peers->http, "new_value", cur_ingress_push_kbps );
2395 0 : jsonp_close_object( peers->http );
2396 0 : }
2397 :
2398 0 : if( FD_UNLIKELY( ref->valid && cur_egress_pull_response_kbps!=ref_egress_pull_response_kbps ) ) {
2399 0 : jsonp_open_object( peers->http, NULL );
2400 0 : jsonp_ulong ( peers->http, "row_index", j );
2401 0 : jsonp_string( peers->http, "column_name", "Egress Pull" );
2402 0 : jsonp_long ( peers->http, "new_value", cur_egress_pull_response_kbps );
2403 0 : jsonp_close_object( peers->http );
2404 0 : }
2405 :
2406 0 : if( FD_UNLIKELY( ref->valid && cur_egress_push_kbps!=ref_egress_push_kbps ) ) {
2407 0 : jsonp_open_object( peers->http, NULL );
2408 0 : jsonp_ulong ( peers->http, "row_index", j );
2409 0 : jsonp_string( peers->http, "column_name", "Egress Push" );
2410 0 : jsonp_long ( peers->http, "new_value", cur_egress_push_kbps );
2411 0 : jsonp_close_object( peers->http );
2412 0 : }
2413 :
2414 0 : }
2415 0 : jsonp_close_array( peers->http );
2416 0 : jsonp_close_object( peers->http );
2417 0 : jsonp_close_envelope( peers->http );
2418 0 : }
2419 :
2420 : void
2421 : fd_gui_printf_peers_viewport_request( fd_gui_peers_ctx_t * peers,
2422 : char const * key,
2423 : ulong ws_conn_id,
2424 0 : ulong request_id ) {
2425 0 : jsonp_open_envelope( peers->http, "gossip", key );
2426 0 : jsonp_ulong( peers->http, "id", request_id );
2427 0 : jsonp_open_object( peers->http, "value" );
2428 :
2429 0 : FD_TEST( peers->client_viewports[ ws_conn_id ].connected );
2430 0 : if( FD_UNLIKELY( peers->client_viewports[ ws_conn_id ].row_cnt>FD_GUI_PEERS_WS_VIEWPORT_MAX_SZ ) ) FD_LOG_ERR(("row_cnt=%lu ws_conn_id=%lu peers->active_ws_conn_id=%lu", peers->client_viewports[ ws_conn_id ].row_cnt, ws_conn_id, peers->active_ws_conn_id ));
2431 0 : for( fd_gui_peers_live_table_fwd_iter_t iter = fd_gui_peers_live_table_fwd_iter_init( peers->live_table, &peers->client_viewports[ ws_conn_id ].sort_key, peers->contact_info_table ), j = 0;
2432 0 : !fd_gui_peers_live_table_fwd_iter_done( iter ) && j<peers->client_viewports[ ws_conn_id ].start_row+peers->client_viewports[ ws_conn_id ].row_cnt;
2433 0 : iter = fd_gui_peers_live_table_fwd_iter_next( iter, peers->contact_info_table ), j++ ) {
2434 0 : if( FD_LIKELY( j<peers->client_viewports[ ws_conn_id ].start_row ) ) continue;
2435 0 : fd_gui_peers_node_t const * cur = fd_gui_peers_live_table_fwd_iter_ele_const( iter, peers->contact_info_table );
2436 :
2437 0 : char row_index_cstr[ 32 ];
2438 0 : FD_TEST( fd_cstr_printf_check( row_index_cstr, sizeof(row_index_cstr), NULL, "%lu", + j ) );
2439 0 : jsonp_open_object( peers->http, row_index_cstr );
2440 : /* This code should be kept in sync with updates to
2441 : fd_gui_peers_live_table */
2442 0 : if( FD_UNLIKELY( cur->stake==ULONG_MAX ) ) jsonp_long ( peers->http, "Stake", -1 );
2443 0 : else jsonp_ulong( peers->http, "Stake", cur->stake );
2444 :
2445 0 : char pubkey_base58[ FD_BASE58_ENCODED_32_SZ ];
2446 0 : fd_base58_encode_32( cur->pubkey.uc, NULL, pubkey_base58 );
2447 0 : jsonp_string( peers->http, "Pubkey", pubkey_base58 );
2448 0 : jsonp_string( peers->http, "Name", cur->name );
2449 0 : jsonp_string( peers->http, "Country", peers->dbip.country_code[ cur->country_code_idx ] );
2450 :
2451 0 : uint ip4 = cur->contact_info.sockets[ FD_GOSSIP_CONTACT_INFO_SOCKET_GOSSIP ].is_ipv6 ? 0U : cur->contact_info.sockets[ FD_GOSSIP_CONTACT_INFO_SOCKET_GOSSIP ].ip4;
2452 0 : char peer_addr[ 16 ]; /* 255.255.255.255 + '\0' */
2453 0 : FD_TEST( fd_cstr_printf_check( peer_addr, sizeof(peer_addr), NULL, FD_IP4_ADDR_FMT, FD_IP4_ADDR_FMT_ARGS( ip4 ) ) );
2454 0 : jsonp_string( peers->http, "IP Addr", peer_addr );
2455 :
2456 0 : long cur_egress_push_kbps = cur->gossip_tx[ FD_METRICS_ENUM_GOSSIP_MESSAGE_V_PUSH_IDX ].rate_ema;
2457 0 : long cur_ingress_push_kbps = cur->gossvf_rx[ FD_METRICS_ENUM_GOSSIP_MESSAGE_V_PUSH_IDX ].rate_ema;
2458 0 : long cur_egress_pull_response_kbps = cur->gossip_tx[ FD_METRICS_ENUM_GOSSIP_MESSAGE_V_PULL_RESPONSE_IDX ].rate_ema;
2459 0 : long cur_ingress_pull_response_kbps = cur->gossvf_rx[ FD_METRICS_ENUM_GOSSIP_MESSAGE_V_PULL_RESPONSE_IDX ].rate_ema;
2460 :
2461 0 : jsonp_long ( peers->http, "Ingress Pull", cur_ingress_pull_response_kbps );
2462 0 : jsonp_long ( peers->http, "Ingress Push", cur_ingress_push_kbps );
2463 0 : jsonp_long ( peers->http, "Egress Pull", cur_egress_pull_response_kbps );
2464 0 : jsonp_long ( peers->http, "Egress Push", cur_egress_push_kbps );
2465 :
2466 0 : jsonp_close_object( peers->http );
2467 0 : }
2468 :
2469 0 : jsonp_close_object( peers->http );
2470 0 : jsonp_close_envelope( peers->http );
2471 0 : }
2472 :
2473 : void
2474 0 : fd_gui_printf_peers_view_resize( fd_gui_peers_ctx_t * peers, ulong sz ) {
2475 0 : jsonp_open_envelope( peers->http, "gossip", "peers_size_update" );
2476 0 : jsonp_ulong( peers->http, "value", sz );
2477 0 : jsonp_close_envelope( peers->http );
2478 0 : }
2479 :
2480 : void
2481 0 : fd_gui_peers_printf_gossip_stats( fd_gui_peers_ctx_t * peers ) {
2482 0 : fd_gui_peers_gossip_stats_t * cur = peers->gossip_stats;
2483 :
2484 0 : jsonp_open_envelope( peers->http, "gossip", "network_stats" );
2485 0 : jsonp_open_object( peers->http, "value" );
2486 :
2487 0 : jsonp_open_object( peers->http, "health" );
2488 0 : jsonp_ulong ( peers->http, "num_push_messages_rx_success", cur->network_health_push_msg_rx_success );
2489 0 : jsonp_ulong ( peers->http, "num_push_messages_rx_failure", cur->network_health_push_msg_rx_failure );
2490 0 : jsonp_ulong ( peers->http, "num_push_entries_rx_success", cur->network_health_push_crds_rx_success );
2491 0 : jsonp_ulong ( peers->http, "num_push_entries_rx_failure", cur->network_health_push_crds_rx_failure );
2492 0 : jsonp_ulong ( peers->http, "num_push_entries_rx_duplicate", cur->network_health_push_crds_rx_duplicate );
2493 0 : jsonp_ulong ( peers->http, "num_pull_response_messages_rx_success", cur->network_health_pull_response_msg_rx_success );
2494 0 : jsonp_ulong ( peers->http, "num_pull_response_messages_rx_failure", cur->network_health_pull_response_msg_rx_failure );
2495 0 : jsonp_ulong ( peers->http, "num_pull_response_entries_rx_success", cur->network_health_pull_response_crds_rx_success );
2496 0 : jsonp_ulong ( peers->http, "num_pull_response_entries_rx_failure", cur->network_health_pull_response_crds_rx_failure );
2497 0 : jsonp_ulong ( peers->http, "num_pull_response_entries_rx_duplicate", cur->network_health_pull_response_crds_rx_duplicate );
2498 0 : jsonp_ulong_as_str( peers->http, "total_stake", cur->network_health_total_stake );
2499 0 : jsonp_ulong ( peers->http, "total_peers", cur->network_health_total_peers );
2500 0 : jsonp_ulong_as_str( peers->http, "connected_stake", cur->network_health_connected_stake );
2501 0 : jsonp_ulong ( peers->http, "connected_staked_peers", cur->network_health_connected_staked_peers );
2502 0 : jsonp_ulong ( peers->http, "connected_unstaked_peers", cur->network_health_connected_unstaked_peers );
2503 0 : jsonp_close_object( peers->http );
2504 :
2505 0 : jsonp_open_object( peers->http, "ingress" );
2506 :
2507 0 : jsonp_open_array( peers->http, "peer_names" );
2508 0 : for( ulong i=0UL; i<cur->network_ingress_peer_sz; i++ ) jsonp_string( peers->http, NULL, cur->network_ingress_peer_names[ i ] );
2509 0 : jsonp_close_array( peers->http );
2510 :
2511 0 : jsonp_open_array( peers->http, "peer_identities" );
2512 0 : for( ulong i=0UL; i<cur->network_ingress_peer_sz; i++ ) {
2513 0 : char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
2514 0 : fd_base58_encode_32( cur->network_ingress_peer_identities[ i ].uc, NULL, identity_base58 );
2515 0 : jsonp_string( peers->http, NULL, identity_base58 );
2516 0 : }
2517 0 : jsonp_close_array( peers->http );
2518 :
2519 0 : jsonp_open_array( peers->http, "peer_throughput" );
2520 0 : for( ulong i=0UL; i<cur->network_ingress_peer_sz; i++ ) jsonp_long( peers->http, NULL, cur->network_ingress_peer_bytes_per_sec[ i ] );
2521 0 : jsonp_close_array( peers->http );
2522 0 : jsonp_long( peers->http, "total_throughput", cur->network_ingress_total_bytes_per_sec );
2523 0 : jsonp_close_object( peers->http );
2524 :
2525 0 : jsonp_open_object( peers->http, "egress" );
2526 0 : jsonp_open_array( peers->http, "peer_names" );
2527 0 : for( ulong i=0UL; i<cur->network_egress_peer_sz; i++ ) jsonp_string( peers->http, NULL, cur->network_egress_peer_names[ i ] );
2528 0 : jsonp_close_array( peers->http );
2529 :
2530 0 : jsonp_open_array( peers->http, "peer_identities" );
2531 0 : for( ulong i=0UL; i<cur->network_egress_peer_sz; i++ ) {
2532 0 : char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
2533 0 : fd_base58_encode_32( cur->network_egress_peer_identities[ i ].uc, NULL, identity_base58 );
2534 0 : jsonp_string( peers->http, NULL, identity_base58 );
2535 0 : }
2536 0 : jsonp_close_array( peers->http );
2537 :
2538 0 : jsonp_open_array( peers->http, "peer_throughput" );
2539 0 : for( ulong i=0UL; i<cur->network_egress_peer_sz; i++ ) jsonp_long( peers->http, NULL, cur->network_egress_peer_bytes_per_sec[ i ] );
2540 0 : jsonp_close_array( peers->http );
2541 0 : jsonp_long( peers->http, "total_throughput", cur->network_egress_total_bytes_per_sec );
2542 0 : jsonp_close_object( peers->http );
2543 :
2544 0 : jsonp_open_object( peers->http, "storage" );
2545 : /* since these are gauges, we don't take a diff */
2546 0 : jsonp_ulong( peers->http, "capacity", cur->storage_capacity );
2547 0 : jsonp_ulong( peers->http, "expired_count", cur->storage_expired_cnt );
2548 0 : jsonp_ulong( peers->http, "evicted_count", cur->storage_evicted_cnt );
2549 0 : jsonp_open_array( peers->http, "count" );
2550 0 : for( ulong i = 0UL; i<FD_METRICS_ENUM_CRDS_VALUE_CNT; i++ ) jsonp_ulong( peers->http, NULL, cur->storage_active_cnt[ i ] );
2551 0 : jsonp_close_array( peers->http );
2552 0 : jsonp_open_array( peers->http, "count_tx" );
2553 0 : for( ulong i = 0UL; i<FD_METRICS_ENUM_CRDS_VALUE_CNT; i++ ) jsonp_ulong( peers->http, NULL, cur->storage_cnt_tx[ i ] );
2554 0 : jsonp_close_array( peers->http );
2555 0 : jsonp_open_array( peers->http, "bytes_tx" );
2556 0 : for( ulong i = 0UL; i<FD_METRICS_ENUM_CRDS_VALUE_CNT; i++ ) jsonp_ulong( peers->http, NULL, cur->storage_bytes_tx[ i ] );
2557 0 : jsonp_close_array( peers->http );
2558 0 : jsonp_close_object( peers->http );
2559 0 : jsonp_open_object( peers->http, "messages" );
2560 0 : jsonp_open_array( peers->http, "num_bytes_rx" );
2561 0 : for( ulong i = 0UL; i<FD_METRICS_ENUM_GOSSIP_MESSAGE_CNT; i++ ) jsonp_ulong( peers->http, NULL, cur->messages_bytes_rx[ i ] );
2562 0 : jsonp_close_array( peers->http );
2563 0 : jsonp_open_array( peers->http, "num_bytes_tx" );
2564 0 : for( ulong i = 0UL; i<FD_METRICS_ENUM_GOSSIP_MESSAGE_CNT; i++ ) jsonp_ulong( peers->http, NULL, cur->messages_bytes_tx[ i ] );
2565 0 : jsonp_close_array( peers->http );
2566 0 : jsonp_open_array( peers->http, "num_messages_rx" );
2567 0 : for( ulong i = 0UL; i<FD_METRICS_ENUM_GOSSIP_MESSAGE_CNT; i++ ) jsonp_ulong( peers->http, NULL, cur->messages_count_rx[ i ] );
2568 0 : jsonp_close_array( peers->http );
2569 0 : jsonp_open_array( peers->http, "num_messages_tx" );
2570 0 : for( ulong i = 0UL; i<FD_METRICS_ENUM_GOSSIP_MESSAGE_CNT; i++ ) jsonp_ulong( peers->http, NULL, cur->messages_count_tx[ i ] );
2571 0 : jsonp_close_array( peers->http );
2572 0 : jsonp_close_object( peers->http );
2573 0 : jsonp_close_object( peers->http );
2574 0 : jsonp_close_envelope( peers->http );
2575 0 : }
2576 :
2577 : void
2578 0 : fd_gui_printf_shreds_staged( fd_gui_t * gui, ulong start_offset, ulong end_offset ) {
2579 0 : ulong min_slot = ULONG_MAX;
2580 0 : long min_ts = LONG_MAX;
2581 :
2582 0 : for( ulong i=start_offset; i<end_offset; i++ ) {
2583 0 : min_slot = fd_ulong_min( min_slot, gui->shreds.staged[ i % FD_GUI_SHREDS_STAGING_SZ ].slot );
2584 0 : min_ts = fd_long_min ( min_ts, gui->shreds.staged[ i % FD_GUI_SHREDS_STAGING_SZ ].timestamp );
2585 0 : }
2586 :
2587 0 : jsonp_ulong ( gui->http, "reference_slot", min_slot );
2588 0 : jsonp_long_as_str( gui->http, "reference_ts", min_ts );
2589 :
2590 0 : jsonp_open_array( gui->http, "slot_delta" );
2591 0 : for( ulong i=start_offset; i<end_offset; i++ ) jsonp_ulong( gui->http, NULL, gui->shreds.staged[ i % FD_GUI_SHREDS_STAGING_SZ ].slot-min_slot );
2592 0 : jsonp_close_array( gui->http );
2593 0 : jsonp_open_array( gui->http, "shred_idx" );
2594 0 : for( ulong i=start_offset; i<end_offset; i++ ) {
2595 0 : if( FD_LIKELY( gui->shreds.staged[ i % FD_GUI_SHREDS_STAGING_SZ ].shred_idx!=USHORT_MAX ) ) jsonp_ulong( gui->http, NULL, gui->shreds.staged[ i % FD_GUI_SHREDS_STAGING_SZ ].shred_idx );
2596 0 : else jsonp_null ( gui->http, NULL );
2597 0 : }
2598 0 : jsonp_close_array( gui->http );
2599 0 : jsonp_open_array( gui->http, "event" );
2600 0 : for( ulong i=start_offset; i<end_offset; i++ ) jsonp_ulong( gui->http, NULL, gui->shreds.staged[ i % FD_GUI_SHREDS_STAGING_SZ ].event );
2601 0 : jsonp_close_array( gui->http );
2602 0 : jsonp_open_array( gui->http, "event_ts_delta" );
2603 0 : for( ulong i=start_offset; i<end_offset; i++ ) jsonp_long_as_str( gui->http, NULL, gui->shreds.staged[ i % FD_GUI_SHREDS_STAGING_SZ ].timestamp-min_ts );
2604 0 : jsonp_close_array( gui->http );
2605 0 : }
2606 :
2607 : void
2608 0 : fd_gui_printf_shreds_history( fd_gui_t * gui, ulong _slot ) {
2609 0 : fd_gui_slot_t * slot = fd_gui_get_slot( gui, _slot );
2610 0 : FD_TEST( slot );
2611 0 : ulong end_offset = slot->shreds.end_offset;
2612 0 : ulong start_offset = slot->shreds.start_offset;
2613 0 : FD_TEST( slot->shreds.end_offset > gui->shreds.history_tail-FD_GUI_SHREDS_HISTORY_SZ );
2614 :
2615 0 : long min_ts = LONG_MAX;
2616 0 : for( ulong i=start_offset; i<end_offset; i++ ) {
2617 0 : min_ts = fd_long_min ( min_ts, gui->shreds.history[ i % FD_GUI_SHREDS_HISTORY_SZ ].timestamp );
2618 0 : }
2619 :
2620 0 : jsonp_ulong ( gui->http, "reference_slot", _slot );
2621 0 : jsonp_long_as_str( gui->http, "reference_ts", min_ts );
2622 :
2623 0 : jsonp_open_array( gui->http, "slot_delta" );
2624 0 : for( ulong i=start_offset; i<end_offset; i++ ) jsonp_ulong( gui->http, NULL, 0UL );
2625 0 : jsonp_close_array( gui->http );
2626 0 : jsonp_open_array( gui->http, "shred_idx" );
2627 0 : for( ulong i=start_offset; i<end_offset; i++ ) {
2628 0 : if( FD_LIKELY( gui->shreds.history[ i % FD_GUI_SHREDS_HISTORY_SZ ].shred_idx!=USHORT_MAX ) ) jsonp_ulong( gui->http, NULL, gui->shreds.history[ i % FD_GUI_SHREDS_HISTORY_SZ ].shred_idx );
2629 0 : else jsonp_null ( gui->http, NULL );
2630 0 : }
2631 0 : jsonp_close_array( gui->http );
2632 0 : jsonp_open_array( gui->http, "event" );
2633 0 : for( ulong i=start_offset; i<end_offset; i++ ) jsonp_ulong( gui->http, NULL, gui->shreds.history[ i % FD_GUI_SHREDS_HISTORY_SZ ].event );
2634 0 : jsonp_close_array( gui->http );
2635 0 : jsonp_open_array( gui->http, "event_ts_delta" );
2636 0 : for( ulong i=start_offset; i<end_offset; i++ ) jsonp_long_as_str( gui->http, NULL, gui->shreds.history[ i % FD_GUI_SHREDS_HISTORY_SZ ].timestamp-min_ts );
2637 0 : jsonp_close_array( gui->http );
2638 0 : }
2639 :
2640 : void
2641 0 : fd_gui_printf_shred_updates( fd_gui_t * gui ) {
2642 0 : jsonp_open_envelope( gui->http, "slot", "live_shreds" );
2643 0 : jsonp_open_object( gui->http, "value" );
2644 0 : fd_gui_printf_shreds_staged( gui, gui->shreds.staged_next_broadcast, gui->shreds.staged_tail );
2645 0 : jsonp_close_object( gui->http );
2646 0 : jsonp_close_envelope( gui->http );
2647 0 : }
2648 :
2649 : void
2650 0 : fd_gui_printf_shred_rebroadcast( fd_gui_t * gui, long after ) {
2651 0 : FD_TEST( gui->shreds.staged_next_broadcast!=ULONG_MAX );
2652 :
2653 0 : ulong _start_offset = gui->shreds.staged_next_broadcast;
2654 0 : for( ulong i=gui->shreds.staged_head; i<gui->shreds.staged_next_broadcast; i++ ) {
2655 0 : if( FD_LIKELY( gui->shreds.staged[ i % FD_GUI_SHREDS_STAGING_SZ ].timestamp<after ) ) continue;
2656 0 : _start_offset = i;
2657 0 : break;
2658 0 : }
2659 :
2660 0 : jsonp_open_envelope( gui->http, "slot", "live_shreds" );
2661 0 : jsonp_open_object( gui->http, "value" );
2662 0 : fd_gui_printf_shreds_staged( gui, _start_offset, gui->shreds.staged_next_broadcast );
2663 0 : jsonp_close_object( gui->http );
2664 0 : jsonp_close_envelope( gui->http );
2665 0 : }
2666 :
2667 : void
2668 : fd_gui_printf_slot_query_shreds( fd_gui_t * gui,
2669 : ulong _slot,
2670 0 : ulong id ) {
2671 0 : jsonp_open_envelope( gui->http, "slot", "query_shreds" );
2672 0 : jsonp_ulong( gui->http, "id", id );
2673 0 : jsonp_open_object( gui->http, "value" );
2674 0 : fd_gui_printf_shreds_history( gui, _slot );
2675 0 : jsonp_close_object( gui->http );
2676 0 : jsonp_close_envelope( gui->http );
2677 0 : }
2678 :
2679 : void
2680 : fd_gui_peers_printf_wfs_add( fd_gui_peers_ctx_t * peers,
2681 : ulong const * idxs,
2682 0 : ulong cnt ) {
2683 0 : jsonp_open_envelope( peers->http, "wait_for_supermajority", "peer_add" );
2684 0 : jsonp_open_array( peers->http, "value" );
2685 0 : for( ulong i=0UL; i<cnt; i++ ) {
2686 0 : fd_gui_wfs_peer_t * wp = &peers->wfs_peers[ idxs[ i ] ];
2687 0 : char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
2688 0 : fd_base58_encode_32( wp->identity_key.uc, NULL, identity_base58 );
2689 0 : jsonp_string( peers->http, NULL, identity_base58 );
2690 0 : }
2691 0 : jsonp_close_array( peers->http );
2692 0 : jsonp_close_envelope( peers->http );
2693 0 : }
2694 :
2695 : void
2696 : fd_gui_peers_printf_wfs_remove( fd_gui_peers_ctx_t * peers,
2697 : ulong const * idxs,
2698 0 : ulong cnt ) {
2699 0 : jsonp_open_envelope( peers->http, "wait_for_supermajority", "peer_remove" );
2700 0 : jsonp_open_array( peers->http, "value" );
2701 0 : for( ulong i=0UL; i<cnt; i++ ) {
2702 0 : fd_gui_wfs_peer_t * wp = &peers->wfs_peers[ idxs[ i ] ];
2703 0 : char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
2704 0 : fd_base58_encode_32( wp->identity_key.uc, NULL, identity_base58 );
2705 0 : jsonp_string( peers->http, NULL, identity_base58 );
2706 0 : }
2707 0 : jsonp_close_array( peers->http );
2708 0 : jsonp_close_envelope( peers->http );
2709 0 : }
2710 :
2711 : void
2712 0 : fd_gui_peers_printf_wfs_stakes( fd_gui_peers_ctx_t * peers ) {
2713 0 : jsonp_open_envelope( peers->http, "wait_for_supermajority", "stakes" );
2714 0 : jsonp_open_object( peers->http, "value" );
2715 :
2716 0 : jsonp_open_array( peers->http, "staked_pubkeys" );
2717 0 : for( ulong i=0UL; i<peers->wfs_peers_cnt; i++ ) {
2718 0 : char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
2719 0 : fd_base58_encode_32( peers->wfs_peers[ i ].identity_key.uc, NULL, identity_base58 );
2720 0 : jsonp_string( peers->http, NULL, identity_base58 );
2721 0 : }
2722 0 : jsonp_close_array( peers->http );
2723 :
2724 0 : jsonp_open_array( peers->http, "staked_lamports" );
2725 0 : for( ulong i=0UL; i<peers->wfs_peers_cnt; i++ ) {
2726 0 : jsonp_ulong_as_str( peers->http, NULL, peers->wfs_peers[ i ].stake );
2727 0 : }
2728 0 : jsonp_close_array( peers->http );
2729 :
2730 0 : jsonp_open_array( peers->http, "infos" );
2731 0 : for( ulong i=0UL; i<peers->wfs_peers_cnt; i++ ) {
2732 0 : fd_gui_config_parse_info_t * info =
2733 0 : fd_gui_peers_node_info_map_ele_query(
2734 0 : peers->node_info_map, &peers->wfs_peers[ i ].identity_key, NULL, peers->node_info_pool );
2735 0 : if( info ) {
2736 0 : jsonp_open_object( peers->http, NULL );
2737 0 : jsonp_string( peers->http, "name", info->name );
2738 0 : jsonp_string( peers->http, "details", info->details );
2739 0 : jsonp_string( peers->http, "website", info->website );
2740 0 : jsonp_string( peers->http, "icon_url", info->icon_uri );
2741 0 : jsonp_string( peers->http, "keybase_username", info->keybase_username );
2742 0 : jsonp_close_object( peers->http );
2743 0 : } else {
2744 0 : jsonp_null( peers->http, NULL );
2745 0 : }
2746 0 : }
2747 0 : jsonp_close_array( peers->http );
2748 :
2749 0 : jsonp_close_object( peers->http );
2750 0 : jsonp_close_envelope( peers->http );
2751 0 : }
|