LCOV - code coverage report
Current view: top level - disco/gui - fd_gui_printf.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 1134 0.0 %
Date: 2025-08-05 05:04:49 Functions: 0 63 0.0 %

          Line data    Source code
       1             : #include <ctype.h>
       2             : #include <stdio.h>
       3             : 
       4             : #include "fd_gui_printf.h"
       5             : 
       6             : #include "../../waltz/http/fd_http_server_private.h"
       7             : #include "../../ballet/utf8/fd_utf8.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_gui_t * gui ) {
      21           0 :   if( FD_LIKELY( !gui->http->stage_err &&
      22           0 :                  gui->http->stage_len>=1UL &&
      23           0 :                  gui->http->oring[ (gui->http->stage_off%gui->http->oring_sz)+gui->http->stage_len-1UL ]==(uchar)',' ) ) {
      24           0 :     gui->http->stage_len--;
      25           0 :   }
      26           0 : }
      27             : 
      28             : static void
      29             : jsonp_open_object( fd_gui_t *   gui,
      30           0 :                    char const * key ) {
      31           0 :   if( FD_LIKELY( key ) ) fd_http_server_printf( gui->http, "\"%s\":{", key );
      32           0 :   else                   fd_http_server_printf( gui->http, "{" );
      33           0 : }
      34             : 
      35             : static void
      36           0 : jsonp_close_object( fd_gui_t * gui ) {
      37           0 :   jsonp_strip_trailing_comma( gui );
      38           0 :   fd_http_server_printf( gui->http, "}," );
      39           0 : }
      40             : 
      41             : static void
      42             : jsonp_open_array( fd_gui_t *   gui,
      43           0 :                   char const * key ) {
      44           0 :   if( FD_LIKELY( key ) ) fd_http_server_printf( gui->http, "\"%s\":[", key );
      45           0 :   else                   fd_http_server_printf( gui->http, "[" );
      46           0 : }
      47             : 
      48             : static void
      49           0 : jsonp_close_array( fd_gui_t * gui ) {
      50           0 :   jsonp_strip_trailing_comma( gui );
      51           0 :   fd_http_server_printf( gui->http, "]," );
      52           0 : }
      53             : 
      54             : static void
      55             : jsonp_ulong( fd_gui_t *   gui,
      56             :              char const * key,
      57           0 :              ulong        value ) {
      58           0 :   if( FD_LIKELY( key ) ) fd_http_server_printf( gui->http, "\"%s\":%lu,", key, value );
      59           0 :   else                   fd_http_server_printf( gui->http, "%lu,", value );
      60           0 : }
      61             : 
      62             : static void
      63             : jsonp_long( fd_gui_t *   gui,
      64             :             char const * key,
      65           0 :             long         value ) {
      66           0 :   if( FD_LIKELY( key ) ) fd_http_server_printf( gui->http, "\"%s\":%ld,", key, value );
      67           0 :   else                   fd_http_server_printf( gui->http, "%ld,", value );
      68           0 : }
      69             : 
      70             : static void
      71             : jsonp_double( fd_gui_t *   gui,
      72             :               char const * key,
      73           0 :               double       value ) {
      74           0 :   if( FD_LIKELY( key ) ) fd_http_server_printf( gui->http, "\"%s\":%.2f,", key, value );
      75           0 :   else                   fd_http_server_printf( gui->http, "%.2f,", value );
      76           0 : }
      77             : 
      78             : static void
      79             : jsonp_ulong_as_str( fd_gui_t *   gui,
      80             :                     char const * key,
      81           0 :                     ulong        value ) {
      82           0 :   if( FD_LIKELY( key ) ) fd_http_server_printf( gui->http, "\"%s\":\"%lu\",", key, value );
      83           0 :   else                   fd_http_server_printf( gui->http, "\"%lu\",", value );
      84           0 : }
      85             : 
      86             : static void
      87             : jsonp_long_as_str( fd_gui_t *   gui,
      88             :                    char const * key,
      89           0 :                    long         value ) {
      90           0 :   if( FD_LIKELY( key ) ) fd_http_server_printf( gui->http, "\"%s\":\"%ld\",", key, value );
      91           0 :   else                   fd_http_server_printf( gui->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_gui_t *   gui,
     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( gui->http, "\"%s\":", key );
     120           0 :   if( FD_LIKELY( val ) ) {
     121           0 :     fd_http_server_printf( gui->http, "\"" );
     122           0 :     ulong start_len = gui->http->stage_len;
     123           0 :     fd_http_server_printf( gui->http, "%s", val );
     124           0 :     jsonp_sanitize_str( gui->http, start_len );
     125           0 :     fd_http_server_printf( gui->http, "\"," );
     126           0 :   } else {
     127           0 :     fd_http_server_printf( gui->http, "null," );
     128           0 :   }
     129           0 : }
     130             : 
     131             : static void
     132             : jsonp_bool( fd_gui_t *   gui,
     133             :             char const * key,
     134           0 :             int          value ) {
     135           0 :   if( FD_LIKELY( key ) ) fd_http_server_printf( gui->http, "\"%s\":%s,", key, value ? "true" : "false" );
     136           0 :   else                   fd_http_server_printf( gui->http, "%s,", value ? "true" : "false" );
     137           0 : }
     138             : 
     139             : static void
     140             : jsonp_null( fd_gui_t *   gui,
     141           0 :             char const * key ) {
     142           0 :   if( FD_LIKELY( key ) ) fd_http_server_printf( gui->http, "\"%s\": null,", key );
     143           0 :   else                   fd_http_server_printf( gui->http, "null," );
     144           0 : }
     145             : 
     146             : static void
     147             : jsonp_open_envelope( fd_gui_t *   gui,
     148             :                      char const * topic,
     149           0 :                      char const * key ) {
     150           0 :   jsonp_open_object( gui, NULL );
     151           0 :   jsonp_string( gui, "topic", topic );
     152           0 :   jsonp_string( gui, "key",   key );
     153           0 : }
     154             : 
     155             : static void
     156           0 : jsonp_close_envelope( fd_gui_t * gui ) {
     157           0 :   jsonp_close_object( gui );
     158           0 :   jsonp_strip_trailing_comma( gui );
     159           0 : }
     160             : 
     161             : void
     162             : fd_gui_printf_open_query_response_envelope( fd_gui_t *   gui,
     163             :                                             char const * topic,
     164             :                                             char const * key,
     165           0 :                                             ulong        id ) {
     166           0 :   jsonp_open_object( gui, NULL );
     167           0 :   jsonp_string( gui, "topic", topic );
     168           0 :   jsonp_string( gui, "key", key );
     169           0 :   jsonp_ulong( gui, "id", id );
     170           0 : }
     171             : 
     172             : void
     173           0 : fd_gui_printf_close_query_response_envelope( fd_gui_t * gui ) {
     174           0 :   jsonp_close_object( gui );
     175           0 :   jsonp_strip_trailing_comma( gui );
     176           0 : }
     177             : 
     178             : void
     179             : fd_gui_printf_null_query_response( fd_gui_t *   gui,
     180             :                                    char const * topic,
     181             :                                    char const * key,
     182           0 :                                    ulong        id ) {
     183           0 :   fd_gui_printf_open_query_response_envelope( gui, topic, key, id );
     184           0 :     jsonp_null( gui, "value" );
     185           0 :   fd_gui_printf_close_query_response_envelope( gui );
     186           0 : }
     187             : 
     188             : void
     189           0 : fd_gui_printf_version( fd_gui_t * gui ) {
     190           0 :   jsonp_open_envelope( gui, "summary", "version" );
     191           0 :     jsonp_string( gui, "value", gui->summary.version );
     192           0 :   jsonp_close_envelope( gui );
     193           0 : }
     194             : 
     195             : void
     196           0 : fd_gui_printf_cluster( fd_gui_t * gui ) {
     197           0 :   jsonp_open_envelope( gui, "summary", "cluster" );
     198           0 :     jsonp_string( gui, "value", gui->summary.cluster );
     199           0 :   jsonp_close_envelope( gui );
     200           0 : }
     201             : 
     202             : void
     203           0 : fd_gui_printf_commit_hash( fd_gui_t * gui ) {
     204           0 :   jsonp_open_envelope( gui, "summary", "commit_hash" );
     205           0 :     jsonp_string( gui, "value", FDCTL_COMMIT_REF_CSTR );
     206           0 :   jsonp_close_envelope( gui );
     207           0 : }
     208             : 
     209             : void
     210           0 : fd_gui_printf_identity_key( fd_gui_t * gui ) {
     211           0 :   jsonp_open_envelope( gui, "summary", "identity_key" );
     212           0 :     jsonp_string( gui, "value", gui->summary.identity_key_base58 );
     213           0 :   jsonp_close_envelope( gui );
     214           0 : }
     215             : 
     216             : void
     217           0 : fd_gui_printf_vote_key( fd_gui_t * gui ) {
     218           0 :   jsonp_open_envelope( gui, "summary", "vote_key" );
     219           0 :     if( FD_LIKELY( gui->summary.has_vote_key ) ) jsonp_string( gui, "value", gui->summary.vote_key_base58 );
     220           0 :     else                                         jsonp_null( gui, "value" );
     221           0 :   jsonp_close_envelope( gui );
     222           0 : }
     223             : 
     224             : void
     225           0 : fd_gui_printf_startup_time_nanos( fd_gui_t * gui ) {
     226           0 :   jsonp_open_envelope( gui, "summary", "startup_time_nanos" );
     227           0 :     jsonp_long_as_str( gui, "value", gui->summary.startup_time_nanos );
     228           0 :   jsonp_close_envelope( gui );
     229           0 : }
     230             : 
     231             : void
     232           0 : fd_gui_printf_vote_distance( fd_gui_t * gui ) {
     233           0 :   jsonp_open_envelope( gui, "summary", "vote_distance" );
     234           0 :     jsonp_ulong( gui, "value", gui->summary.vote_distance );
     235           0 :   jsonp_close_envelope( gui );
     236           0 : }
     237             : 
     238             : 
     239             : void
     240           0 : fd_gui_printf_vote_state( fd_gui_t * gui ) {
     241           0 :   jsonp_open_envelope( gui, "summary", "vote_state" );
     242           0 :     switch( gui->summary.vote_state ) {
     243           0 :       case FD_GUI_VOTE_STATE_NON_VOTING:
     244           0 :         jsonp_string( gui, "value", "non-voting" );
     245           0 :         break;
     246           0 :       case FD_GUI_VOTE_STATE_VOTING:
     247           0 :         jsonp_string( gui, "value", "voting" );
     248           0 :         break;
     249           0 :       case FD_GUI_VOTE_STATE_DELINQUENT:
     250           0 :         jsonp_string( gui, "value", "delinquent" );
     251           0 :         break;
     252           0 :       default:
     253           0 :         FD_LOG_ERR(( "unknown vote state %d", gui->summary.vote_state ));
     254           0 :     }
     255           0 :   jsonp_close_envelope( gui );
     256           0 : }
     257             : 
     258             : void
     259           0 : fd_gui_printf_skipped_history( fd_gui_t * gui ) {
     260           0 :   jsonp_open_envelope( gui, "slot", "skipped_history" );
     261           0 :     jsonp_open_array( gui, "value" );
     262           0 :       for( ulong i=0UL; i<fd_ulong_min( gui->summary.slot_completed+1, FD_GUI_SLOTS_CNT ); i++ ) {
     263           0 :         ulong _slot = gui->summary.slot_completed-i;
     264           0 :         fd_gui_slot_t * slot = gui->slots[ _slot % FD_GUI_SLOTS_CNT ];
     265             : 
     266           0 :         if( FD_UNLIKELY( slot->slot!=_slot ) ) break;
     267           0 :         if( FD_UNLIKELY( slot->mine && slot->skipped ) ) jsonp_ulong( gui, NULL, slot->slot );
     268           0 :       }
     269           0 :     jsonp_close_array( gui );
     270           0 :   jsonp_close_envelope( gui );
     271           0 : }
     272             : 
     273             : void
     274           0 : fd_gui_printf_tps_history( fd_gui_t * gui ) {
     275           0 :   jsonp_open_envelope( gui, "summary", "tps_history" );
     276           0 :     jsonp_open_array( gui, "value" );
     277             : 
     278           0 :     for( ulong i=0UL; i<FD_GUI_TPS_HISTORY_SAMPLE_CNT; i++ ) {
     279           0 :       ulong idx = (gui->summary.estimated_tps_history_idx+i) % FD_GUI_TPS_HISTORY_SAMPLE_CNT;
     280           0 :       jsonp_open_array( gui, NULL );
     281           0 :         jsonp_double( gui, NULL, (double)gui->summary.estimated_tps_history[ idx ][ 0 ]/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
     282           0 :         jsonp_double( gui, NULL, (double)gui->summary.estimated_tps_history[ idx ][ 1 ]/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
     283           0 :         jsonp_double( gui, NULL, (double)(gui->summary.estimated_tps_history[ idx ][ 0 ] - gui->summary.estimated_tps_history[ idx ][ 1 ] - gui->summary.estimated_tps_history[ idx ][ 2 ])/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
     284           0 :         jsonp_double( gui, NULL, (double)gui->summary.estimated_tps_history[ idx ][ 2 ]/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
     285           0 :       jsonp_close_array( gui );
     286           0 :     }
     287             : 
     288           0 :     jsonp_close_array( gui );
     289           0 :   jsonp_close_envelope( gui );
     290           0 : }
     291             : 
     292             : void
     293           0 : fd_gui_printf_startup_progress( fd_gui_t * gui ) {
     294           0 :   char const * phase;
     295             : 
     296           0 :   switch( gui->summary.startup_progress ) {
     297           0 :     case FD_GUI_START_PROGRESS_TYPE_INITIALIZING:
     298           0 :       phase = "initializing";
     299           0 :       break;
     300           0 :     case FD_GUI_START_PROGRESS_TYPE_SEARCHING_FOR_FULL_SNAPSHOT:
     301           0 :       phase = "searching_for_full_snapshot";
     302           0 :       break;
     303           0 :     case FD_GUI_START_PROGRESS_TYPE_DOWNLOADING_FULL_SNAPSHOT:
     304           0 :       phase = "downloading_full_snapshot";
     305           0 :       break;
     306           0 :     case FD_GUI_START_PROGRESS_TYPE_SEARCHING_FOR_INCREMENTAL_SNAPSHOT:
     307           0 :       phase = "searching_for_incremental_snapshot";
     308           0 :       break;
     309           0 :     case FD_GUI_START_PROGRESS_TYPE_DOWNLOADING_INCREMENTAL_SNAPSHOT:
     310           0 :       phase = "downloading_incremental_snapshot";
     311           0 :       break;
     312           0 :     case FD_GUI_START_PROGRESS_TYPE_CLEANING_BLOCK_STORE:
     313           0 :       phase = "cleaning_blockstore";
     314           0 :       break;
     315           0 :     case FD_GUI_START_PROGRESS_TYPE_CLEANING_ACCOUNTS:
     316           0 :       phase = "cleaning_accounts";
     317           0 :       break;
     318           0 :     case FD_GUI_START_PROGRESS_TYPE_LOADING_LEDGER:
     319           0 :       phase = "loading_ledger";
     320           0 :       break;
     321           0 :     case FD_GUI_START_PROGRESS_TYPE_PROCESSING_LEDGER:
     322           0 :       phase = "processing_ledger";
     323           0 :       break;
     324           0 :     case FD_GUI_START_PROGRESS_TYPE_STARTING_SERVICES:
     325           0 :       phase = "starting_services";
     326           0 :       break;
     327           0 :     case FD_GUI_START_PROGRESS_TYPE_HALTED:
     328           0 :       phase = "halted";
     329           0 :       break;
     330           0 :     case FD_GUI_START_PROGRESS_TYPE_WAITING_FOR_SUPERMAJORITY:
     331           0 :       phase = "waiting_for_supermajority";
     332           0 :       break;
     333           0 :     case FD_GUI_START_PROGRESS_TYPE_RUNNING:
     334           0 :       phase = "running";
     335           0 :       break;
     336           0 :     default:
     337           0 :       FD_LOG_ERR(( "unknown phase %d", gui->summary.startup_progress ));
     338           0 :   }
     339             : 
     340           0 :   jsonp_open_envelope( gui, "summary", "startup_progress" );
     341           0 :     jsonp_open_object( gui, "value" );
     342           0 :       jsonp_string( gui, "phase", phase );
     343           0 :       if( FD_LIKELY( gui->summary.startup_progress>=FD_GUI_START_PROGRESS_TYPE_DOWNLOADING_FULL_SNAPSHOT) ) {
     344           0 :         char peer_addr[ 64 ];
     345           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_full_snapshot_peer_ip_addr), gui->summary.startup_full_snapshot_peer_port ) );
     346             : 
     347           0 :         jsonp_string( gui, "downloading_full_snapshot_peer", peer_addr );
     348           0 :         jsonp_ulong( gui, "downloading_full_snapshot_slot", gui->summary.startup_full_snapshot_slot );
     349           0 :         jsonp_double( gui, "downloading_full_snapshot_elapsed_secs", gui->summary.startup_full_snapshot_elapsed_secs );
     350           0 :         jsonp_double( gui, "downloading_full_snapshot_remaining_secs", gui->summary.startup_full_snapshot_remaining_secs );
     351           0 :         jsonp_double( gui, "downloading_full_snapshot_throughput", gui->summary.startup_full_snapshot_throughput );
     352           0 :         jsonp_ulong( gui, "downloading_full_snapshot_total_bytes", gui->summary.startup_full_snapshot_total_bytes );
     353           0 :         jsonp_ulong( gui, "downloading_full_snapshot_current_bytes", gui->summary.startup_full_snapshot_current_bytes );
     354           0 :       } else {
     355           0 :         jsonp_null( gui, "downloading_full_snapshot_peer" );
     356           0 :         jsonp_null( gui, "downloading_full_snapshot_slot" );
     357           0 :         jsonp_null( gui, "downloading_full_snapshot_elapsed_secs" );
     358           0 :         jsonp_null( gui, "downloading_full_snapshot_remaining_secs" );
     359           0 :         jsonp_null( gui, "downloading_full_snapshot_throughput" );
     360           0 :         jsonp_null( gui, "downloading_full_snapshot_total_bytes" );
     361           0 :         jsonp_null( gui, "downloading_full_snapshot_current_bytes" );
     362           0 :       }
     363             : 
     364           0 :       if( FD_LIKELY( gui->summary.startup_progress>=FD_GUI_START_PROGRESS_TYPE_DOWNLOADING_INCREMENTAL_SNAPSHOT) ) {
     365           0 :         char peer_addr[ 64 ];
     366           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_incremental_snapshot_peer_ip_addr), gui->summary.startup_incremental_snapshot_peer_port ) );
     367             : 
     368           0 :         jsonp_string( gui, "downloading_incremental_snapshot_peer", peer_addr );
     369           0 :         jsonp_ulong( gui, "downloading_incremental_snapshot_slot", gui->summary.startup_incremental_snapshot_slot );
     370           0 :         jsonp_double( gui, "downloading_incremental_snapshot_elapsed_secs", gui->summary.startup_incremental_snapshot_elapsed_secs );
     371           0 :         jsonp_double( gui, "downloading_incremental_snapshot_remaining_secs", gui->summary.startup_incremental_snapshot_remaining_secs );
     372           0 :         jsonp_double( gui, "downloading_incremental_snapshot_throughput", gui->summary.startup_incremental_snapshot_throughput );
     373           0 :         jsonp_ulong( gui, "downloading_incremental_snapshot_total_bytes", gui->summary.startup_incremental_snapshot_total_bytes );
     374           0 :         jsonp_ulong( gui, "downloading_incremental_snapshot_current_bytes", gui->summary.startup_incremental_snapshot_current_bytes );
     375           0 :       } else {
     376           0 :         jsonp_null( gui, "downloading_incremental_snapshot_peer" );
     377           0 :         jsonp_null( gui, "downloading_incremental_snapshot_slot" );
     378           0 :         jsonp_null( gui, "downloading_incremental_snapshot_elapsed_secs" );
     379           0 :         jsonp_null( gui, "downloading_incremental_snapshot_remaining_secs" );
     380           0 :         jsonp_null( gui, "downloading_incremental_snapshot_throughput" );
     381           0 :         jsonp_null( gui, "downloading_incremental_snapshot_total_bytes" );
     382           0 :         jsonp_null( gui, "downloading_incremental_snapshot_current_bytes" );
     383           0 :       }
     384             : 
     385           0 :       if( FD_LIKELY( gui->summary.startup_progress>=FD_GUI_START_PROGRESS_TYPE_PROCESSING_LEDGER) ) {
     386           0 :         jsonp_ulong( gui, "ledger_slot",     gui->summary.startup_ledger_slot );
     387           0 :         jsonp_ulong( gui, "ledger_max_slot", gui->summary.startup_ledger_max_slot );
     388           0 :       } else {
     389           0 :         jsonp_null( gui, "ledger_slot" );
     390           0 :         jsonp_null( gui, "ledger_max_slot" );
     391           0 :       }
     392             : 
     393           0 :       if( FD_LIKELY( gui->summary.startup_progress>=FD_GUI_START_PROGRESS_TYPE_WAITING_FOR_SUPERMAJORITY ) && gui->summary.startup_waiting_for_supermajority_slot!=ULONG_MAX ) {
     394           0 :         jsonp_ulong( gui, "waiting_for_supermajority_slot",      gui->summary.startup_waiting_for_supermajority_slot );
     395           0 :         jsonp_ulong( gui, "waiting_for_supermajority_stake_percent", gui->summary.startup_waiting_for_supermajority_stake_pct );
     396           0 :       } else {
     397           0 :         jsonp_null( gui, "waiting_for_supermajority_slot" );
     398           0 :         jsonp_null( gui, "waiting_for_supermajority_stake_percent" );
     399           0 :       }
     400           0 :     jsonp_close_object( gui );
     401           0 :   jsonp_close_envelope( gui );
     402           0 : }
     403             : 
     404             : void
     405           0 : fd_gui_printf_block_engine( fd_gui_t * gui ) {
     406           0 :   jsonp_open_envelope( gui, "block_engine", "update" );
     407           0 :     jsonp_open_object( gui, "value" );
     408           0 :       jsonp_string( gui, "name",   gui->block_engine.name );
     409           0 :       jsonp_string( gui, "url",    gui->block_engine.url );
     410           0 :       jsonp_string( gui, "ip",     gui->block_engine.ip_cstr );
     411           0 :       if( FD_LIKELY( gui->block_engine.status==1 ) )      jsonp_string( gui, "status", "connecting" );
     412           0 :       else if( FD_LIKELY( gui->block_engine.status==2 ) ) jsonp_string( gui, "status", "connected" );
     413           0 :       else                                                jsonp_string( gui, "status", "disconnected" );
     414           0 :     jsonp_close_object( gui );
     415           0 :   jsonp_close_envelope( gui );
     416           0 : }
     417             : 
     418             : void
     419           0 : fd_gui_printf_tiles( fd_gui_t * gui ) {
     420           0 :   jsonp_open_envelope( gui, "summary", "tiles" );
     421           0 :     jsonp_open_array( gui, "value" );
     422           0 :       for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
     423           0 :         fd_topo_tile_t const * tile = &gui->topo->tiles[ i ];
     424             : 
     425           0 :         if( FD_UNLIKELY( !strncmp( tile->name, "bench", 5UL ) ) ) {
     426             :           /* bench tiles not reported */
     427           0 :           continue;
     428           0 :         }
     429             : 
     430           0 :         jsonp_open_object( gui, NULL );
     431           0 :           jsonp_string( gui, "kind", tile->name );
     432           0 :           jsonp_ulong( gui, "kind_id", tile->kind_id );
     433           0 :         jsonp_close_object( gui );
     434           0 :       }
     435           0 :     jsonp_close_array( gui );
     436           0 :   jsonp_close_envelope( gui );
     437           0 : }
     438             : 
     439             : void
     440           0 : fd_gui_printf_schedule_strategy( fd_gui_t * gui ) {
     441           0 :   jsonp_open_envelope( gui, "summary", "schedule_strategy" );
     442           0 :     char mode[10];
     443           0 :     switch (gui->summary.schedule_strategy) {
     444           0 :       case 0: strncpy( mode, "perf", sizeof(mode) ); break;
     445           0 :       case 1: strncpy( mode, "balanced", sizeof(mode) ); break;
     446           0 :       case 2: strncpy( mode, "revenue", sizeof(mode) ); break;
     447           0 :       default: FD_LOG_ERR(("unexpected schedule_strategy %d", gui->summary.schedule_strategy));
     448           0 :     }
     449           0 :     mode[ sizeof(mode) - 1] = '\0';
     450           0 :     jsonp_string( gui, "value", mode );
     451           0 :   jsonp_close_envelope( gui );
     452           0 : }
     453             : 
     454             : void
     455           0 : fd_gui_printf_identity_balance( fd_gui_t * gui ) {
     456           0 :   jsonp_open_envelope( gui, "summary", "identity_balance" );
     457           0 :     jsonp_ulong_as_str( gui, "value", gui->summary.identity_account_balance );
     458           0 :   jsonp_close_envelope( gui );
     459           0 : }
     460             : 
     461             : void
     462           0 : fd_gui_printf_vote_balance( fd_gui_t * gui ) {
     463           0 :   jsonp_open_envelope( gui, "summary", "vote_balance" );
     464           0 :     jsonp_ulong_as_str( gui, "value", gui->summary.vote_account_balance );
     465           0 :   jsonp_close_envelope( gui );
     466           0 : }
     467             : 
     468             : void
     469           0 : fd_gui_printf_estimated_slot_duration_nanos( fd_gui_t * gui ) {
     470           0 :   jsonp_open_envelope( gui, "summary", "estimated_slot_duration_nanos" );
     471           0 :     jsonp_ulong( gui, "value", gui->summary.estimated_slot_duration_nanos );
     472           0 :   jsonp_close_envelope( gui );
     473           0 : }
     474             : 
     475             : 
     476             : void
     477           0 : fd_gui_printf_root_slot( fd_gui_t * gui ) {
     478           0 :   jsonp_open_envelope( gui, "summary", "root_slot" );
     479           0 :     jsonp_ulong( gui, "value", gui->summary.slot_rooted );
     480           0 :   jsonp_close_envelope( gui );
     481           0 : }
     482             : 
     483             : void
     484           0 : fd_gui_printf_optimistically_confirmed_slot( fd_gui_t * gui ) {
     485           0 :   jsonp_open_envelope( gui, "summary", "optimistically_confirmed_slot" );
     486           0 :     jsonp_ulong( gui, "value", gui->summary.slot_optimistically_confirmed );
     487           0 :   jsonp_close_envelope( gui );
     488           0 : }
     489             : 
     490             : void
     491           0 : fd_gui_printf_completed_slot( fd_gui_t * gui ) {
     492           0 :   jsonp_open_envelope( gui, "summary", "completed_slot" );
     493           0 :     jsonp_ulong( gui, "value", gui->summary.slot_completed );
     494           0 :   jsonp_close_envelope( gui );
     495           0 : }
     496             : 
     497             : void
     498           0 : fd_gui_printf_estimated_slot( fd_gui_t * gui ) {
     499           0 :   jsonp_open_envelope( gui, "summary", "estimated_slot" );
     500           0 :     jsonp_ulong( gui, "value", gui->summary.slot_estimated );
     501           0 :   jsonp_close_envelope( gui );
     502           0 : }
     503             : 
     504             : void
     505             : fd_gui_printf_skip_rate( fd_gui_t * gui,
     506           0 :                          ulong      epoch_idx ) {
     507           0 :   jsonp_open_envelope( gui, "summary", "skip_rate" );
     508           0 :     jsonp_open_object( gui, "value" );
     509           0 :       jsonp_ulong( gui, "epoch", gui->epoch.epochs[ epoch_idx ].epoch );
     510           0 :       if( FD_UNLIKELY( !gui->epoch.epochs[ epoch_idx ].my_total_slots ) ) jsonp_double( gui, "skip_rate", 0.0 );
     511           0 :       else                                                                jsonp_double( gui, "skip_rate", (double)gui->epoch.epochs[ epoch_idx ].my_skipped_slots/(double)gui->epoch.epochs[ epoch_idx ].my_total_slots );
     512           0 :     jsonp_close_object( gui );
     513           0 :   jsonp_close_envelope( gui );
     514           0 : }
     515             : 
     516             : void
     517             : fd_gui_printf_epoch( fd_gui_t * gui,
     518           0 :                      ulong      epoch_idx ) {
     519           0 :   jsonp_open_envelope( gui, "epoch", "new" );
     520           0 :     jsonp_open_object( gui, "value" );
     521           0 :       jsonp_ulong( gui, "epoch",                   gui->epoch.epochs[ epoch_idx ].epoch );
     522           0 :       if( FD_LIKELY( gui->epoch.epochs[ epoch_idx ].start_time!=LONG_MAX ) ) jsonp_ulong_as_str( gui, "start_time_nanos", (ulong)gui->epoch.epochs[ epoch_idx ].start_time );
     523           0 :       else                                                                    jsonp_null( gui, "start_time_nanos" );
     524           0 :       if( FD_LIKELY( gui->epoch.epochs[ epoch_idx ].end_time!=LONG_MAX ) ) jsonp_ulong_as_str( gui, "end_time_nanos", (ulong)gui->epoch.epochs[ epoch_idx ].end_time );
     525           0 :       else                                                                  jsonp_null( gui, "end_time_nanos" );
     526           0 :       jsonp_ulong( gui, "start_slot",              gui->epoch.epochs[ epoch_idx ].start_slot );
     527           0 :       jsonp_ulong( gui, "end_slot",                gui->epoch.epochs[ epoch_idx ].end_slot );
     528           0 :       jsonp_ulong_as_str( gui, "excluded_stake_lamports", gui->epoch.epochs[ epoch_idx ].excluded_stake );
     529           0 :       jsonp_open_array( gui, "staked_pubkeys" );
     530           0 :         fd_epoch_leaders_t * lsched = gui->epoch.epochs[epoch_idx].lsched;
     531           0 :         for( ulong i=0UL; i<lsched->pub_cnt; i++ ) {
     532           0 :           char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
     533           0 :           fd_base58_encode_32( lsched->pub[ i ].uc, NULL, identity_base58 );
     534           0 :           jsonp_string( gui, NULL, identity_base58 );
     535           0 :         }
     536           0 :       jsonp_close_array( gui );
     537             : 
     538           0 :       jsonp_open_array( gui, "staked_lamports" );
     539           0 :         fd_vote_stake_weight_t * stakes = gui->epoch.epochs[epoch_idx].stakes;
     540           0 :         for( ulong i=0UL; i<lsched->pub_cnt; i++ ) jsonp_ulong_as_str( gui, NULL, stakes[ i ].stake );
     541           0 :       jsonp_close_array( gui );
     542             : 
     543           0 :       jsonp_open_array( gui, "leader_slots" );
     544           0 :         for( ulong i = 0; i < lsched->sched_cnt; i++ ) jsonp_ulong( gui, NULL, lsched->sched[ i ] );
     545           0 :       jsonp_close_array( gui );
     546           0 :     jsonp_close_object( gui );
     547           0 :   jsonp_close_envelope( gui );
     548           0 : }
     549             : 
     550             : static void
     551             : fd_gui_printf_waterfall( fd_gui_t *               gui,
     552             :                          fd_gui_txn_waterfall_t const * prev,
     553           0 :                          fd_gui_txn_waterfall_t const * cur ) {
     554           0 :   jsonp_open_object( gui, "waterfall" );
     555           0 :     jsonp_open_object( gui, "in" );
     556           0 :       jsonp_ulong( gui, "pack_cranked",    cur->in.pack_cranked - prev->in.pack_cranked );
     557           0 :       jsonp_ulong( gui, "pack_retained",   prev->out.pack_retained );
     558           0 :       jsonp_ulong( gui, "resolv_retained", prev->out.resolv_retained );
     559           0 :       jsonp_ulong( gui, "quic",            cur->in.quic   - prev->in.quic );
     560           0 :       jsonp_ulong( gui, "udp",             cur->in.udp    - prev->in.udp );
     561           0 :       jsonp_ulong( gui, "gossip",          cur->in.gossip - prev->in.gossip );
     562           0 :       jsonp_ulong( gui, "block_engine",    cur->in.block_engine - prev->in.block_engine );
     563           0 :     jsonp_close_object( gui );
     564             : 
     565           0 :     jsonp_open_object( gui, "out" );
     566           0 :       jsonp_ulong( gui, "net_overrun",         cur->out.net_overrun         - prev->out.net_overrun );
     567           0 :       jsonp_ulong( gui, "quic_overrun",        cur->out.quic_overrun        - prev->out.quic_overrun );
     568           0 :       jsonp_ulong( gui, "quic_frag_drop",      cur->out.quic_frag_drop      - prev->out.quic_frag_drop );
     569           0 :       jsonp_ulong( gui, "quic_abandoned",      cur->out.quic_abandoned      - prev->out.quic_abandoned );
     570           0 :       jsonp_ulong( gui, "tpu_quic_invalid",    cur->out.tpu_quic_invalid    - prev->out.tpu_quic_invalid );
     571           0 :       jsonp_ulong( gui, "tpu_udp_invalid",     cur->out.tpu_udp_invalid     - prev->out.tpu_udp_invalid );
     572           0 :       jsonp_ulong( gui, "verify_overrun",      cur->out.verify_overrun      - prev->out.verify_overrun );
     573           0 :       jsonp_ulong( gui, "verify_parse",        cur->out.verify_parse        - prev->out.verify_parse );
     574           0 :       jsonp_ulong( gui, "verify_failed",       cur->out.verify_failed       - prev->out.verify_failed );
     575           0 :       jsonp_ulong( gui, "verify_duplicate",    cur->out.verify_duplicate    - prev->out.verify_duplicate );
     576           0 :       jsonp_ulong( gui, "dedup_duplicate",     cur->out.dedup_duplicate     - prev->out.dedup_duplicate );
     577           0 :       jsonp_ulong( gui, "resolv_lut_failed",   cur->out.resolv_lut_failed   - prev->out.resolv_lut_failed );
     578           0 :       jsonp_ulong( gui, "resolv_expired",      cur->out.resolv_expired      - prev->out.resolv_expired );
     579           0 :       jsonp_ulong( gui, "resolv_ancient",      cur->out.resolv_ancient      - prev->out.resolv_ancient );
     580           0 :       jsonp_ulong( gui, "resolv_no_ledger",    cur->out.resolv_no_ledger    - prev->out.resolv_no_ledger );
     581           0 :       jsonp_ulong( gui, "resolv_retained",     cur->out.resolv_retained );
     582           0 :       jsonp_ulong( gui, "pack_invalid",        cur->out.pack_invalid        - prev->out.pack_invalid );
     583           0 :       jsonp_ulong( gui, "pack_invalid_bundle", cur->out.pack_invalid_bundle - prev->out.pack_invalid_bundle );
     584           0 :       jsonp_ulong( gui, "pack_expired",        cur->out.pack_expired        - prev->out.pack_expired );
     585           0 :       jsonp_ulong( gui, "pack_retained",       cur->out.pack_retained );
     586           0 :       jsonp_ulong( gui, "pack_wait_full",      cur->out.pack_wait_full      - prev->out.pack_wait_full );
     587           0 :       jsonp_ulong( gui, "pack_leader_slow",    cur->out.pack_leader_slow    - prev->out.pack_leader_slow );
     588           0 :       jsonp_ulong( gui, "bank_invalid",        cur->out.bank_invalid        - prev->out.bank_invalid );
     589           0 :       jsonp_ulong( gui, "block_success",       cur->out.block_success       - prev->out.block_success );
     590           0 :       jsonp_ulong( gui, "block_fail",          cur->out.block_fail          - prev->out.block_fail );
     591           0 :     jsonp_close_object( gui );
     592           0 :   jsonp_close_object( gui );
     593           0 : }
     594             : 
     595             : void
     596             : fd_gui_printf_live_txn_waterfall( fd_gui_t *                     gui,
     597             :                                   fd_gui_txn_waterfall_t const * prev,
     598             :                                   fd_gui_txn_waterfall_t const * cur,
     599           0 :                                   ulong                          next_leader_slot ) {
     600           0 :   jsonp_open_envelope( gui, "summary", "live_txn_waterfall" );
     601           0 :     jsonp_open_object( gui, "value" );
     602           0 :       jsonp_ulong( gui, "next_leader_slot", next_leader_slot );
     603           0 :       fd_gui_printf_waterfall( gui, prev, cur );
     604           0 :     jsonp_close_object( gui );
     605           0 :   jsonp_close_envelope( gui );
     606           0 : }
     607             : 
     608             : static void
     609             : fd_gui_printf_tile_stats( fd_gui_t *                  gui,
     610             :                           fd_gui_tile_stats_t const * prev,
     611           0 :                           fd_gui_tile_stats_t const * cur ) {
     612           0 :   jsonp_open_object( gui, "tile_primary_metric" );
     613           0 :     jsonp_ulong(  gui, "quic",    cur->quic_conn_cnt );
     614           0 :     jsonp_double( gui, "bundle_rtt_smoothed_millis", (double)(cur->bundle_rtt_smoothed_nanos) / 1000000.0 );
     615             : 
     616           0 :     fd_histf_t bundle_rx_delay_hist_delta[ 1 ];
     617           0 :     fd_histf_subtract( gui->bundle_rx_delay_hist_current, gui->bundle_rx_delay_hist_reference, bundle_rx_delay_hist_delta );
     618           0 :     ulong bundle_rx_delay_nanos_p90 = fd_histf_percentile( bundle_rx_delay_hist_delta, 90U, ULONG_MAX );
     619           0 :     jsonp_double( gui, "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 ));
     620             : 
     621           0 :     if( FD_LIKELY( cur->sample_time_nanos>prev->sample_time_nanos ) ) {
     622           0 :       jsonp_ulong( gui, "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) ));
     623           0 :       jsonp_ulong( gui, "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) ));
     624           0 :     } else {
     625           0 :       jsonp_ulong( gui, "net_in",  0 );
     626           0 :       jsonp_ulong( gui, "net_out", 0 );
     627           0 :     }
     628           0 :     if( FD_LIKELY( cur->verify_total_cnt>prev->verify_total_cnt ) ) {
     629           0 :       jsonp_double( gui, "verify", (double)(cur->verify_drop_cnt-prev->verify_drop_cnt) / (double)(cur->verify_total_cnt-prev->verify_total_cnt) );
     630           0 :     } else {
     631           0 :       jsonp_double( gui, "verify", 0.0 );
     632           0 :     }
     633           0 :     if( FD_LIKELY( cur->dedup_total_cnt>prev->dedup_total_cnt ) ) {
     634           0 :       jsonp_double( gui, "dedup", (double)(cur->dedup_drop_cnt-prev->dedup_drop_cnt) / (double)(cur->dedup_total_cnt-prev->dedup_total_cnt) );
     635           0 :     } else {
     636           0 :       jsonp_double( gui, "dedup", 0.0 );
     637           0 :     }
     638           0 :     jsonp_ulong(  gui, "bank", cur->bank_txn_exec_cnt - prev->bank_txn_exec_cnt );
     639           0 :     jsonp_double( gui, "pack", !cur->pack_buffer_capacity ? 1.0 : (double)cur->pack_buffer_cnt/(double)cur->pack_buffer_capacity );
     640           0 :     jsonp_double( gui, "poh", 0.0 );
     641           0 :     jsonp_double( gui, "shred", 0.0 );
     642           0 :     jsonp_double( gui, "store", 0.0 );
     643           0 :   jsonp_close_object( gui );
     644           0 : }
     645             : 
     646             : void
     647             : fd_gui_printf_live_tile_stats( fd_gui_t *                  gui,
     648             :                                fd_gui_tile_stats_t const * prev,
     649           0 :                                fd_gui_tile_stats_t const * cur ) {
     650           0 :   jsonp_open_envelope( gui, "summary", "live_tile_primary_metric" );
     651           0 :     jsonp_open_object( gui, "value" );
     652           0 :       jsonp_ulong( gui, "next_leader_slot", 0UL );
     653           0 :       fd_gui_printf_tile_stats( gui, prev, cur );
     654           0 :     jsonp_close_object( gui );
     655           0 :   jsonp_close_envelope( gui );
     656           0 : }
     657             : 
     658             : static void
     659             : fd_gui_printf_tile_timers( fd_gui_t *                   gui,
     660             :                            fd_gui_tile_timers_t const * prev,
     661           0 :                            fd_gui_tile_timers_t const * cur ) {
     662           0 :   for( ulong i=0UL; i<gui->topo->tile_cnt; i++ ) {
     663           0 :     fd_topo_tile_t const * tile = &gui->topo->tiles[ i ];
     664             : 
     665           0 :     if( FD_UNLIKELY( !strncmp( tile->name, "bench", 5UL ) ) ) {
     666             :       /* bench tiles not reported */
     667           0 :       continue;
     668           0 :     }
     669             : 
     670           0 :     double cur_total = (double)(cur[ i ].caughtup_housekeeping_ticks
     671           0 :                                 + cur[ i ].processing_housekeeping_ticks
     672           0 :                                 + cur[ i ].backpressure_housekeeping_ticks
     673           0 :                                 + cur[ i ].caughtup_prefrag_ticks
     674           0 :                                 + cur[ i ].processing_prefrag_ticks
     675           0 :                                 + cur[ i ].backpressure_prefrag_ticks
     676           0 :                                 + cur[ i ].caughtup_postfrag_ticks
     677           0 :                                 + cur[ i ].processing_postfrag_ticks);
     678             : 
     679           0 :     double prev_total = (double)(prev[ i ].caughtup_housekeeping_ticks
     680           0 :                                   + prev[ i ].processing_housekeeping_ticks
     681           0 :                                   + prev[ i ].backpressure_housekeeping_ticks
     682           0 :                                   + prev[ i ].caughtup_prefrag_ticks
     683           0 :                                   + prev[ i ].processing_prefrag_ticks
     684           0 :                                   + prev[ i ].backpressure_prefrag_ticks
     685           0 :                                   + prev[ i ].caughtup_postfrag_ticks
     686           0 :                                   + prev[ i ].processing_postfrag_ticks);
     687             : 
     688           0 :     double idle;
     689           0 :     if( FD_UNLIKELY( cur_total==prev_total ) ) {
     690             :       /* The tile didn't sample timers since the last sample, unclear what
     691             :          idleness should be so send -1. NaN would be better but no NaN in
     692             :          JSON. */
     693           0 :       idle = -1;
     694           0 :     } else {
     695           0 :       idle = (double)(cur[ i ].caughtup_postfrag_ticks - prev[ i ].caughtup_postfrag_ticks) / (cur_total - prev_total);
     696           0 :     }
     697             : 
     698           0 :     jsonp_double( gui, NULL, idle );
     699           0 :   }
     700           0 : }
     701             : 
     702             : void
     703           0 : fd_gui_printf_live_tile_timers( fd_gui_t * gui ) {
     704           0 :   jsonp_open_envelope( gui, "summary", "live_tile_timers" );
     705           0 :     jsonp_open_array( gui, "value" );
     706           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 ];
     707           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 ];
     708           0 :       fd_gui_printf_tile_timers( gui, prev, cur );
     709           0 :     jsonp_close_array( gui );
     710           0 :   jsonp_close_envelope( gui );
     711           0 : }
     712             : 
     713             : void
     714           0 : fd_gui_printf_estimated_tps( fd_gui_t * gui ) {
     715           0 :   ulong idx = (gui->summary.estimated_tps_history_idx+FD_GUI_TPS_HISTORY_SAMPLE_CNT-1UL) % FD_GUI_TPS_HISTORY_SAMPLE_CNT;
     716             : 
     717           0 :   jsonp_open_envelope( gui, "summary", "estimated_tps" );
     718           0 :     jsonp_open_object( gui, "value" );
     719           0 :       jsonp_double( gui, "total",           (double)gui->summary.estimated_tps_history[ idx ][ 0 ]/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
     720           0 :       jsonp_double( gui, "vote",            (double)gui->summary.estimated_tps_history[ idx ][ 1 ]/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
     721           0 :       jsonp_double( gui, "nonvote_success", (double)(gui->summary.estimated_tps_history[ idx ][ 0 ] - gui->summary.estimated_tps_history[ idx ][ 1 ] - gui->summary.estimated_tps_history[ idx ][ 2 ])/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
     722           0 :       jsonp_double( gui, "nonvote_failed",  (double)gui->summary.estimated_tps_history[ idx ][ 2 ]/(double)FD_GUI_TPS_HISTORY_WINDOW_DURATION_SECONDS );
     723           0 :     jsonp_close_object( gui );
     724           0 :   jsonp_close_envelope( gui );
     725           0 : }
     726             : 
     727             : static int
     728             : fd_gui_gossip_contains( fd_gui_t const * gui,
     729           0 :                         uchar const *    pubkey ) {
     730           0 :   for( ulong i=0UL; i<gui->gossip.peer_cnt; i++ ) {
     731           0 :     if( FD_UNLIKELY( !memcmp( gui->gossip.peers[ i ].pubkey->uc, pubkey, 32 ) ) ) return 1;
     732           0 :   }
     733           0 :   return 0;
     734           0 : }
     735             : 
     736             : static int
     737             : fd_gui_vote_acct_contains( fd_gui_t const * gui,
     738           0 :                            uchar const *    pubkey ) {
     739           0 :   for( ulong i=0UL; i<gui->vote_account.vote_account_cnt; i++ ) {
     740           0 :     if( FD_UNLIKELY( !memcmp( gui->vote_account.vote_accounts[ i ].pubkey, pubkey, 32 ) ) ) return 1;
     741           0 :   }
     742           0 :   return 0;
     743           0 : }
     744             : 
     745             : static int
     746             : fd_gui_validator_info_contains( fd_gui_t const * gui,
     747           0 :                                 uchar const *    pubkey ) {
     748           0 :   for( ulong i=0UL; i<gui->validator_info.info_cnt; i++ ) {
     749           0 :     if( FD_UNLIKELY( !memcmp( gui->validator_info.info[ i ].pubkey, pubkey, 32 ) ) ) return 1;
     750           0 :   }
     751           0 :   return 0;
     752           0 : }
     753             : 
     754             : static void
     755             : fd_gui_printf_peer( fd_gui_t *    gui,
     756           0 :                     uchar const * identity_pubkey ) {
     757           0 :   ulong gossip_idx = ULONG_MAX;
     758           0 :   ulong info_idx = ULONG_MAX;
     759           0 :   ulong vote_idxs[ FD_GUI_MAX_PEER_CNT ] = {0};
     760           0 :   ulong vote_idx_cnt = 0UL;
     761             : 
     762           0 :   for( ulong i=0UL; i<gui->gossip.peer_cnt; i++ ) {
     763           0 :     if( FD_UNLIKELY( !memcmp( gui->gossip.peers[ i ].pubkey->uc, identity_pubkey, 32 ) ) ) {
     764           0 :       gossip_idx = i;
     765           0 :       break;
     766           0 :     }
     767           0 :   }
     768             : 
     769           0 :   for( ulong i=0UL; i<gui->validator_info.info_cnt; i++ ) {
     770           0 :     if( FD_UNLIKELY( !memcmp( gui->validator_info.info[ i ].pubkey, identity_pubkey, 32 ) ) ) {
     771           0 :       info_idx = i;
     772           0 :       break;
     773           0 :     }
     774           0 :   }
     775             : 
     776           0 :   for( ulong i=0UL; i<gui->vote_account.vote_account_cnt; i++ ) {
     777           0 :     if( FD_UNLIKELY( !memcmp( gui->vote_account.vote_accounts[ i ].pubkey, identity_pubkey, 32 ) ) ) {
     778           0 :       vote_idxs[ vote_idx_cnt++ ] = i;
     779           0 :     }
     780           0 :   }
     781             : 
     782           0 :   jsonp_open_object( gui, NULL );
     783             : 
     784           0 :     char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
     785           0 :     fd_base58_encode_32( identity_pubkey, NULL, identity_base58 );
     786           0 :     jsonp_string( gui, "identity_pubkey", identity_base58 );
     787             : 
     788           0 :     if( FD_UNLIKELY( gossip_idx==ULONG_MAX ) ) {
     789           0 :       jsonp_string( gui, "gossip", NULL );
     790           0 :     } else {
     791           0 :       jsonp_open_object( gui, "gossip" );
     792             : 
     793           0 :         char version[ 32 ];
     794           0 :         FD_TEST( fd_cstr_printf( version, sizeof( version ), NULL, "%u.%u.%u", gui->gossip.peers[ gossip_idx ].version.major, gui->gossip.peers[ gossip_idx ].version.minor, gui->gossip.peers[ gossip_idx ].version.patch ) );
     795           0 :         jsonp_string( gui, "version", version );
     796           0 :         jsonp_ulong( gui, "feature_set", gui->gossip.peers[ gossip_idx ].version.feature_set );
     797           0 :         jsonp_ulong( gui, "wallclock", gui->gossip.peers[ gossip_idx ].wallclock );
     798           0 :         jsonp_ulong( gui, "shred_version", gui->gossip.peers[ gossip_idx ].shred_version );
     799           0 :         jsonp_open_object( gui, "sockets" );
     800           0 :           for( ulong j=0UL; j<12UL; j++ ) {
     801           0 :             if( FD_LIKELY( !gui->gossip.peers[ gossip_idx ].sockets[ j ].ipv4 && !gui->gossip.peers[ gossip_idx ].sockets[ j ].port ) ) continue;
     802           0 :             char const * tag;
     803           0 :             switch( j ) {
     804           0 :               case  0: tag = "gossip";            break;
     805           0 :               case  1: tag = "rpc";               break;
     806           0 :               case  2: tag = "rpb_pubsub";        break;
     807           0 :               case  3: tag = "serve_repair";      break;
     808           0 :               case  4: tag = "serve_repair_quic"; break;
     809           0 :               case  5: tag = "tpu";               break;
     810           0 :               case  6: tag = "tpu_quic";          break;
     811           0 :               case  7: tag = "tvu";               break;
     812           0 :               case  8: tag = "tvu_quic";          break;
     813           0 :               case  9: tag = "tpu_forwards";      break;
     814           0 :               case 10: tag = "tpu_forwards_quic"; break;
     815           0 :               case 11: tag = "tpu_vote";          break;
     816           0 :             }
     817           0 :             char line[ 64 ];
     818           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 ) );
     819           0 :             jsonp_string( gui, tag, line );
     820           0 :           }
     821           0 :         jsonp_close_object( gui );
     822             : 
     823           0 :       jsonp_close_object( gui );
     824           0 :     }
     825             : 
     826           0 :     jsonp_open_array( gui, "vote" );
     827           0 :       for( ulong i=0UL; i<vote_idx_cnt; i++ ) {
     828           0 :         jsonp_open_object( gui, NULL );
     829           0 :           char vote_account_base58[ FD_BASE58_ENCODED_32_SZ ];
     830           0 :           fd_base58_encode_32( gui->vote_account.vote_accounts[ vote_idxs[ i ] ].vote_account->uc, NULL, vote_account_base58 );
     831           0 :           jsonp_string( gui, "vote_account", vote_account_base58 );
     832           0 :           jsonp_ulong_as_str( gui, "activated_stake", gui->vote_account.vote_accounts[ vote_idxs[ i ] ].activated_stake );
     833           0 :           jsonp_ulong( gui, "last_vote", gui->vote_account.vote_accounts[ vote_idxs[ i ] ].last_vote );
     834           0 :           jsonp_ulong( gui, "root_slot", gui->vote_account.vote_accounts[ vote_idxs[ i ] ].root_slot );
     835           0 :           jsonp_ulong( gui, "epoch_credits", gui->vote_account.vote_accounts[ vote_idxs[ i ] ].epoch_credits );
     836           0 :           jsonp_ulong( gui, "commission", gui->vote_account.vote_accounts[ vote_idxs[ i ] ].commission );
     837           0 :           jsonp_bool( gui, "delinquent", gui->vote_account.vote_accounts[ vote_idxs[ i ] ].delinquent );
     838           0 :         jsonp_close_object( gui );
     839           0 :       }
     840           0 :     jsonp_close_array( gui );
     841             : 
     842           0 :     if( FD_UNLIKELY( info_idx==ULONG_MAX ) ) {
     843           0 :       jsonp_string( gui, "info", NULL );
     844           0 :     } else {
     845           0 :       jsonp_open_object( gui, "info" );
     846           0 :         jsonp_string( gui, "name", gui->validator_info.info[ info_idx ].name );
     847           0 :         jsonp_string( gui, "details", gui->validator_info.info[ info_idx ].details );
     848           0 :         jsonp_string( gui, "website", gui->validator_info.info[ info_idx ].website );
     849           0 :         jsonp_string( gui, "icon_url", gui->validator_info.info[ info_idx ].icon_uri );
     850           0 :       jsonp_close_object( gui );
     851           0 :     }
     852             : 
     853           0 :   jsonp_close_object( gui );
     854           0 : }
     855             : 
     856             : void
     857             : fd_gui_printf_peers_gossip_update( fd_gui_t *          gui,
     858             :                                    ulong const *       updated,
     859             :                                    ulong               updated_cnt,
     860             :                                    fd_pubkey_t const * removed,
     861             :                                    ulong               removed_cnt,
     862             :                                    ulong const *       added,
     863           0 :                                    ulong               added_cnt ) {
     864           0 :   jsonp_open_envelope( gui, "peers", "update" );
     865           0 :     jsonp_open_object( gui, "value" );
     866           0 :       jsonp_open_array( gui, "add" );
     867           0 :         for( ulong i=0UL; i<added_cnt; i++ ) {
     868           0 :           int actually_added = !fd_gui_vote_acct_contains( gui, gui->gossip.peers[ added[ i ] ].pubkey->uc ) &&
     869           0 :                                !fd_gui_validator_info_contains( gui, gui->gossip.peers[ added[ i ] ].pubkey->uc );
     870           0 :           if( FD_LIKELY( !actually_added ) ) continue;
     871             : 
     872           0 :           fd_gui_printf_peer( gui, gui->gossip.peers[ added[ i ] ].pubkey->uc );
     873           0 :         }
     874           0 :       jsonp_close_array( gui );
     875             : 
     876           0 :       jsonp_open_array( gui, "update" );
     877           0 :         for( ulong i=0UL; i<added_cnt; i++ ) {
     878           0 :           int actually_added = !fd_gui_vote_acct_contains( gui, gui->gossip.peers[ added[ i ] ].pubkey->uc ) &&
     879           0 :                               !fd_gui_validator_info_contains( gui, gui->gossip.peers[ added[ i ] ].pubkey->uc );
     880           0 :           if( FD_LIKELY( actually_added ) ) continue;
     881             : 
     882           0 :           fd_gui_printf_peer( gui, gui->gossip.peers[ added[ i ] ].pubkey->uc );
     883           0 :         }
     884           0 :         for( ulong i=0UL; i<updated_cnt; i++ ) {
     885           0 :           fd_gui_printf_peer( gui, gui->gossip.peers[ updated[ i ] ].pubkey->uc );
     886           0 :         }
     887           0 :       jsonp_close_array( gui );
     888             : 
     889           0 :       jsonp_open_array( gui, "remove" );
     890           0 :         for( ulong i=0UL; i<removed_cnt; i++ ) {
     891           0 :           int actually_removed = !fd_gui_vote_acct_contains( gui, removed[ i ].uc ) &&
     892           0 :                                  !fd_gui_validator_info_contains( gui, removed[ i ].uc );
     893           0 :           if( FD_UNLIKELY( !actually_removed ) ) continue;
     894             : 
     895           0 :           jsonp_open_object( gui, NULL );
     896           0 :             char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
     897           0 :             fd_base58_encode_32( removed[ i ].uc, NULL, identity_base58 );
     898           0 :             jsonp_string( gui, "identity_pubkey", identity_base58 );
     899           0 :           jsonp_close_object( gui );
     900           0 :         }
     901           0 :       jsonp_close_array( gui );
     902           0 :     jsonp_close_object( gui );
     903           0 :   jsonp_close_envelope( gui );
     904           0 : }
     905             : 
     906             : void
     907             : fd_gui_printf_peers_vote_account_update( fd_gui_t *          gui,
     908             :                                          ulong const *       updated,
     909             :                                          ulong               updated_cnt,
     910             :                                          fd_pubkey_t const * removed,
     911             :                                          ulong               removed_cnt,
     912             :                                          ulong const *       added,
     913           0 :                                          ulong               added_cnt ) {
     914           0 :   jsonp_open_envelope( gui, "peers", "update" );
     915           0 :     jsonp_open_object( gui, "value" );
     916           0 :       jsonp_open_array( gui, "add" );
     917           0 :       for( ulong i=0UL; i<added_cnt; i++ ) {
     918           0 :         int actually_added = !fd_gui_gossip_contains( gui, gui->vote_account.vote_accounts[ added[ i ] ].pubkey->uc ) &&
     919           0 :                              !fd_gui_validator_info_contains( gui, gui->vote_account.vote_accounts[ added[ i ] ].pubkey->uc );
     920           0 :         if( FD_LIKELY( !actually_added ) ) continue;
     921             : 
     922           0 :         fd_gui_printf_peer( gui, gui->vote_account.vote_accounts[ added[ i ] ].pubkey->uc );
     923           0 :       }
     924           0 :       jsonp_close_array( gui );
     925             : 
     926           0 :       jsonp_open_array( gui, "update" );
     927           0 :       for( ulong i=0UL; i<added_cnt; i++ ) {
     928           0 :         int actually_added = !fd_gui_gossip_contains( gui, gui->vote_account.vote_accounts[ added[ i ] ].pubkey->uc ) &&
     929           0 :                              !fd_gui_validator_info_contains( gui, gui->vote_account.vote_accounts[ added[ i ] ].pubkey->uc );
     930           0 :         if( FD_LIKELY( actually_added ) ) continue;
     931             : 
     932           0 :         fd_gui_printf_peer( gui, gui->vote_account.vote_accounts[ added[ i ] ].pubkey->uc );
     933           0 :       }
     934           0 :       for( ulong i=0UL; i<updated_cnt; i++ ) {
     935           0 :         fd_gui_printf_peer( gui, gui->vote_account.vote_accounts[ updated[ i ] ].pubkey->uc );
     936           0 :       }
     937           0 :       jsonp_close_array( gui );
     938             : 
     939           0 :       jsonp_open_array( gui, "remove" );
     940           0 :       for( ulong i=0UL; i<removed_cnt; i++ ) {
     941           0 :         int actually_removed = !fd_gui_gossip_contains( gui, gui->vote_account.vote_accounts[ added[ i ] ].pubkey->uc ) &&
     942           0 :                                !fd_gui_validator_info_contains( gui, gui->vote_account.vote_accounts[ added[ i ] ].pubkey->uc );
     943           0 :         if( FD_UNLIKELY( !actually_removed ) ) continue;
     944             : 
     945           0 :         jsonp_open_object( gui, NULL );
     946           0 :           char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
     947           0 :           fd_base58_encode_32( removed[ i ].uc, NULL, identity_base58 );
     948           0 :           jsonp_string( gui, "identity_pubkey", identity_base58 );
     949           0 :         jsonp_close_object( gui );
     950           0 :       }
     951           0 :       jsonp_close_array( gui );
     952           0 :     jsonp_close_object( gui );
     953           0 :   jsonp_close_envelope( gui );
     954           0 : }
     955             : 
     956             : void
     957             : fd_gui_printf_peers_validator_info_update( fd_gui_t *          gui,
     958             :                                            ulong const *       updated,
     959             :                                            ulong               updated_cnt,
     960             :                                            fd_pubkey_t const * removed,
     961             :                                            ulong               removed_cnt,
     962             :                                            ulong const *       added,
     963           0 :                                            ulong               added_cnt ) {
     964           0 :   jsonp_open_envelope( gui, "peers", "update" );
     965           0 :     jsonp_open_object( gui, "value" );
     966           0 :       jsonp_open_array( gui, "add" );
     967           0 :       for( ulong i=0UL; i<added_cnt; i++ ) {
     968           0 :         int actually_added = !fd_gui_gossip_contains( gui, gui->validator_info.info[ added[ i ] ].pubkey->uc ) &&
     969           0 :                              !fd_gui_vote_acct_contains( gui, gui->validator_info.info[ added[ i ] ].pubkey->uc );
     970           0 :         if( FD_LIKELY( !actually_added ) ) continue;
     971             : 
     972           0 :         fd_gui_printf_peer( gui, gui->validator_info.info[ added[ i ] ].pubkey->uc );
     973           0 :       }
     974           0 :       jsonp_close_array( gui );
     975             : 
     976           0 :       jsonp_open_array( gui, "update" );
     977           0 :       for( ulong i=0UL; i<added_cnt; i++ ) {
     978           0 :         int actually_added = !fd_gui_gossip_contains( gui, gui->validator_info.info[ added[ i ] ].pubkey->uc ) &&
     979           0 :                              !fd_gui_vote_acct_contains( gui, gui->validator_info.info[ added[ i ] ].pubkey->uc );
     980           0 :         if( FD_LIKELY( actually_added ) ) continue;
     981             : 
     982           0 :         fd_gui_printf_peer( gui, gui->validator_info.info[ added[ i ] ].pubkey->uc );
     983           0 :       }
     984           0 :       for( ulong i=0UL; i<updated_cnt; i++ ) {
     985           0 :         fd_gui_printf_peer( gui, gui->validator_info.info[ updated[ i ] ].pubkey->uc );
     986           0 :       }
     987           0 :       jsonp_close_array( gui );
     988             : 
     989           0 :       jsonp_open_array( gui, "remove" );
     990           0 :       for( ulong i=0UL; i<removed_cnt; i++ ) {
     991           0 :         int actually_removed = !fd_gui_gossip_contains( gui, gui->validator_info.info[ added[ i ] ].pubkey->uc ) &&
     992           0 :                                !fd_gui_vote_acct_contains( gui, gui->validator_info.info[ added[ i ] ].pubkey->uc );
     993           0 :         if( FD_UNLIKELY( !actually_removed ) ) continue;
     994             : 
     995           0 :         jsonp_open_object( gui, NULL );
     996           0 :           char identity_base58[ FD_BASE58_ENCODED_32_SZ ];
     997           0 :           fd_base58_encode_32( removed[ i ].uc, NULL, identity_base58 );
     998           0 :           jsonp_string( gui, "identity_pubkey", identity_base58 );
     999           0 :         jsonp_close_object( gui );
    1000           0 :       }
    1001           0 :       jsonp_close_array( gui );
    1002           0 :     jsonp_close_object( gui );
    1003           0 :   jsonp_close_envelope( gui );
    1004           0 : }
    1005             : 
    1006             : void
    1007           0 : fd_gui_printf_peers_all( fd_gui_t * gui ) {
    1008           0 :   jsonp_open_envelope( gui, "peers", "update" );
    1009           0 :     jsonp_open_object( gui, "value" );
    1010           0 :       jsonp_open_array( gui, "add" );
    1011           0 :       for( ulong i=0UL; i<gui->gossip.peer_cnt; i++ ) {
    1012           0 :         fd_gui_printf_peer( gui, gui->gossip.peers[ i ].pubkey->uc );
    1013           0 :       }
    1014           0 :       for( ulong i=0UL; i<gui->vote_account.vote_account_cnt; i++ ) {
    1015           0 :         int actually_added = !fd_gui_gossip_contains( gui, gui->vote_account.vote_accounts[ i ].pubkey->uc );
    1016           0 :         if( FD_UNLIKELY( actually_added ) ) {
    1017           0 :           fd_gui_printf_peer( gui, gui->vote_account.vote_accounts[ i ].pubkey->uc );
    1018           0 :         }
    1019           0 :       }
    1020           0 :       for( ulong i=0UL; i<gui->validator_info.info_cnt; i++ ) {
    1021           0 :         int actually_added = !fd_gui_gossip_contains( gui, gui->validator_info.info[ i ].pubkey->uc ) &&
    1022           0 :                              !fd_gui_vote_acct_contains( gui, gui->validator_info.info[ i ].pubkey->uc );
    1023           0 :         if( FD_UNLIKELY( actually_added ) ) {
    1024           0 :           fd_gui_printf_peer( gui, gui->validator_info.info[ i ].pubkey->uc );
    1025           0 :         }
    1026           0 :       }
    1027           0 :       jsonp_close_array( gui );
    1028           0 :     jsonp_close_object( gui );
    1029           0 :   jsonp_close_envelope( gui );
    1030           0 : }
    1031             : 
    1032             : static void
    1033             : fd_gui_printf_ts_tile_timers( fd_gui_t *                   gui,
    1034             :                               fd_gui_tile_timers_t const * prev,
    1035           0 :                               fd_gui_tile_timers_t const * cur ) {
    1036           0 :   jsonp_open_object( gui, NULL );
    1037           0 :     jsonp_ulong_as_str( gui, "timestamp_nanos", 0 );
    1038           0 :     jsonp_open_array( gui, "tile_timers" );
    1039           0 :       fd_gui_printf_tile_timers( gui, prev, cur );
    1040           0 :     jsonp_close_array( gui );
    1041           0 :   jsonp_close_object( gui );
    1042           0 : }
    1043             : 
    1044             : void
    1045             : fd_gui_printf_slot( fd_gui_t * gui,
    1046           0 :                     ulong      _slot ) {
    1047           0 :   fd_gui_slot_t * slot = gui->slots[ _slot % FD_GUI_SLOTS_CNT ];
    1048             : 
    1049           0 :   char const * level;
    1050           0 :   switch( slot->level ) {
    1051           0 :     case FD_GUI_SLOT_LEVEL_INCOMPLETE:               level = "incomplete"; break;
    1052           0 :     case FD_GUI_SLOT_LEVEL_COMPLETED:                level = "completed";  break;
    1053           0 :     case FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED: level = "optimistically_confirmed"; break;
    1054           0 :     case FD_GUI_SLOT_LEVEL_ROOTED:                   level = "rooted"; break;
    1055           0 :     case FD_GUI_SLOT_LEVEL_FINALIZED:                level = "finalized"; break;
    1056           0 :     default:                                         level = "unknown"; break;
    1057           0 :   }
    1058             : 
    1059           0 :   fd_gui_slot_t * parent_slot = gui->slots[ slot->parent_slot % FD_GUI_SLOTS_CNT ];
    1060           0 :   if( FD_UNLIKELY( parent_slot->slot!=slot->parent_slot ) ) parent_slot = NULL;
    1061             : 
    1062           0 :   long duration_nanos = LONG_MAX;
    1063           0 :   if( FD_LIKELY( slot->completed_time!=LONG_MAX && parent_slot && parent_slot->completed_time!=LONG_MAX ) ) {
    1064           0 :     duration_nanos = slot->completed_time - parent_slot->completed_time;
    1065           0 :   }
    1066             : 
    1067           0 :   jsonp_open_envelope( gui, "slot", "update" );
    1068           0 :     jsonp_open_object( gui, "value" );
    1069           0 :       jsonp_open_object( gui, "publish" );
    1070           0 :         jsonp_ulong( gui, "slot", _slot );
    1071           0 :         jsonp_bool( gui, "mine", slot->mine );
    1072           0 :         jsonp_bool( gui, "skipped", slot->skipped );
    1073           0 :         if( FD_UNLIKELY( duration_nanos==LONG_MAX ) ) jsonp_null( gui, "duration_nanos" );
    1074           0 :         else                                          jsonp_long( gui, "duration_nanos", duration_nanos );
    1075           0 :         if( FD_UNLIKELY( slot->completed_time==LONG_MAX ) ) jsonp_null( gui, "completed_time_nanos" );
    1076           0 :         else                                                jsonp_long_as_str( gui, "completed_time_nanos", slot->completed_time );
    1077           0 :         jsonp_string( gui, "level", level );
    1078           0 :         if( FD_UNLIKELY( slot->total_txn_cnt==UINT_MAX
    1079           0 :                          || slot->vote_txn_cnt==UINT_MAX
    1080           0 :                          || slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "success_nonvote_transaction_cnt" );
    1081           0 :         else                                                           jsonp_ulong( gui, "success_nonvote_transaction_cnt", slot->total_txn_cnt - slot->vote_txn_cnt - slot->nonvote_failed_txn_cnt );
    1082           0 :         if( FD_UNLIKELY( slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "failed_nonvote_transaction_cnt" );
    1083           0 :         else                                                        jsonp_ulong( gui, "failed_nonvote_transaction_cnt", slot->nonvote_failed_txn_cnt );
    1084           0 :         if( FD_UNLIKELY( slot->vote_txn_cnt==UINT_MAX
    1085           0 :                          || slot->failed_txn_cnt==UINT_MAX
    1086           0 :                          || slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "success_vote_transaction_cnt" );
    1087           0 :         else                                                           jsonp_ulong( gui, "success_vote_transaction_cnt", slot->vote_txn_cnt - (slot->failed_txn_cnt - slot->nonvote_failed_txn_cnt) );
    1088           0 :         if( FD_UNLIKELY( slot->failed_txn_cnt==UINT_MAX
    1089           0 :                          || slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "failed_vote_transaction_cnt" );
    1090           0 :         else                                                           jsonp_ulong( gui, "failed_vote_transaction_cnt", slot->failed_txn_cnt - slot->nonvote_failed_txn_cnt );
    1091           0 :         if( FD_UNLIKELY( slot->max_compute_units==UINT_MAX ) ) jsonp_null( gui, "max_compute_units" );
    1092           0 :         else                                                       jsonp_ulong( gui, "max_compute_units", slot->max_compute_units );
    1093           0 :         if( FD_UNLIKELY( slot->compute_units==UINT_MAX ) ) jsonp_null( gui, "compute_units" );
    1094           0 :         else                                               jsonp_ulong( gui, "compute_units", slot->compute_units );
    1095           0 :         if( FD_UNLIKELY( slot->transaction_fee==ULONG_MAX ) ) jsonp_null( gui, "transaction_fee" );
    1096           0 :         else                                                  jsonp_ulong_as_str( gui, "transaction_fee", slot->transaction_fee );
    1097           0 :         if( FD_UNLIKELY( slot->priority_fee==ULONG_MAX ) ) jsonp_null( gui, "priority_fee" );
    1098           0 :         else                                               jsonp_ulong_as_str( gui, "priority_fee", slot->priority_fee );
    1099           0 :         if( FD_UNLIKELY( slot->tips==ULONG_MAX ) ) jsonp_null( gui, "tips" );
    1100           0 :         else                                       jsonp_ulong_as_str( gui, "tips", slot->tips );
    1101           0 :       jsonp_close_object( gui );
    1102           0 :     jsonp_close_object( gui );
    1103           0 :   jsonp_close_envelope( gui );
    1104           0 : }
    1105             : 
    1106             : void
    1107             : fd_gui_printf_summary_ping( fd_gui_t * gui,
    1108           0 :                             ulong      id ) {
    1109           0 :   jsonp_open_envelope( gui, "summary", "ping" );
    1110           0 :     jsonp_ulong( gui, "id", id );
    1111           0 :     jsonp_null( gui, "value" );
    1112           0 :   jsonp_close_envelope( gui );
    1113           0 : }
    1114             : 
    1115             : void
    1116             : fd_gui_printf_slot_request( fd_gui_t * gui,
    1117             :                             ulong      _slot,
    1118           0 :                             ulong      id ) {
    1119           0 :   fd_gui_slot_t * slot = gui->slots[ _slot % FD_GUI_SLOTS_CNT ];
    1120             : 
    1121           0 :   char const * level;
    1122           0 :   switch( slot->level ) {
    1123           0 :     case FD_GUI_SLOT_LEVEL_INCOMPLETE:               level = "incomplete"; break;
    1124           0 :     case FD_GUI_SLOT_LEVEL_COMPLETED:                level = "completed";  break;
    1125           0 :     case FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED: level = "optimistically_confirmed"; break;
    1126           0 :     case FD_GUI_SLOT_LEVEL_ROOTED:                   level = "rooted"; break;
    1127           0 :     case FD_GUI_SLOT_LEVEL_FINALIZED:                level = "finalized"; break;
    1128           0 :     default:                                         level = "unknown"; break;
    1129           0 :   }
    1130             : 
    1131           0 :   fd_gui_slot_t * parent_slot = gui->slots[ slot->parent_slot % FD_GUI_SLOTS_CNT ];
    1132           0 :   if( FD_UNLIKELY( parent_slot->slot!=slot->parent_slot ) ) parent_slot = NULL;
    1133             : 
    1134           0 :   long duration_nanos = LONG_MAX;
    1135           0 :   if( FD_LIKELY( slot->completed_time!=LONG_MAX && parent_slot && parent_slot->completed_time!=LONG_MAX ) ) {
    1136           0 :     duration_nanos = slot->completed_time - parent_slot->completed_time;
    1137           0 :   }
    1138             : 
    1139           0 :   jsonp_open_envelope( gui, "slot", "query" );
    1140           0 :     jsonp_ulong( gui, "id", id );
    1141           0 :     jsonp_open_object( gui, "value" );
    1142             : 
    1143           0 :       jsonp_open_object( gui, "publish" );
    1144           0 :         jsonp_ulong( gui, "slot", _slot );
    1145           0 :         jsonp_bool( gui, "mine", slot->mine );
    1146           0 :         jsonp_bool( gui, "skipped", slot->skipped );
    1147           0 :         jsonp_string( gui, "level", level );
    1148           0 :         if( FD_UNLIKELY( duration_nanos==LONG_MAX ) ) jsonp_null( gui, "duration_nanos" );
    1149           0 :         else                                          jsonp_long( gui, "duration_nanos", duration_nanos );
    1150           0 :         if( FD_UNLIKELY( slot->completed_time==LONG_MAX ) ) jsonp_null( gui, "completed_time_nanos" );
    1151           0 :         else                                                jsonp_long( gui, "completed_time_nanos", slot->completed_time );
    1152           0 :         if( FD_UNLIKELY( slot->total_txn_cnt==UINT_MAX
    1153           0 :                          || slot->vote_txn_cnt==UINT_MAX
    1154           0 :                          || slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "success_nonvote_transaction_cnt" );
    1155           0 :         else                                                           jsonp_ulong( gui, "success_nonvote_transaction_cnt", slot->total_txn_cnt - slot->vote_txn_cnt - slot->nonvote_failed_txn_cnt );
    1156           0 :         if( FD_UNLIKELY( slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "failed_nonvote_transaction_cnt" );
    1157           0 :         else                                                        jsonp_ulong( gui, "failed_nonvote_transaction_cnt", slot->nonvote_failed_txn_cnt );
    1158           0 :         if( FD_UNLIKELY( slot->vote_txn_cnt==UINT_MAX
    1159           0 :                          || slot->failed_txn_cnt==UINT_MAX
    1160           0 :                          || slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "success_vote_transaction_cnt" );
    1161           0 :         else                                                           jsonp_ulong( gui, "success_vote_transaction_cnt", slot->vote_txn_cnt - (slot->failed_txn_cnt - slot->nonvote_failed_txn_cnt) );
    1162           0 :         if( FD_UNLIKELY( slot->failed_txn_cnt==UINT_MAX
    1163           0 :                          || slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "failed_vote_transaction_cnt" );
    1164           0 :         else                                                           jsonp_ulong( gui, "failed_vote_transaction_cnt", slot->failed_txn_cnt - slot->nonvote_failed_txn_cnt );
    1165           0 :         if( FD_UNLIKELY( slot->max_compute_units==UINT_MAX ) ) jsonp_null( gui, "max_compute_units" );
    1166           0 :         else                                                       jsonp_ulong( gui, "max_compute_units", slot->max_compute_units );
    1167           0 :         if( FD_UNLIKELY( slot->compute_units==UINT_MAX ) ) jsonp_null( gui, "compute_units" );
    1168           0 :         else                                               jsonp_ulong( gui, "compute_units", slot->compute_units );
    1169           0 :         if( FD_UNLIKELY( slot->transaction_fee==ULONG_MAX ) ) jsonp_null( gui, "transaction_fee" );
    1170           0 :         else                                                  jsonp_ulong( gui, "transaction_fee", slot->transaction_fee );
    1171           0 :         if( FD_UNLIKELY( slot->priority_fee==ULONG_MAX ) ) jsonp_null( gui, "priority_fee" );
    1172           0 :         else                                               jsonp_ulong( gui, "priority_fee", slot->priority_fee );
    1173           0 :         if( FD_UNLIKELY( slot->tips==ULONG_MAX ) ) jsonp_null( gui, "tips" );
    1174           0 :         else                                       jsonp_ulong( gui, "tips", slot->tips );
    1175           0 :       jsonp_close_object( gui );
    1176             : 
    1177           0 :     jsonp_close_object( gui );
    1178           0 :   jsonp_close_envelope( gui );
    1179           0 : }
    1180             : 
    1181             : void
    1182             : fd_gui_printf_slot_transactions_request( fd_gui_t * gui,
    1183             :                                          ulong      _slot,
    1184           0 :                                          ulong      id ) {
    1185           0 :   fd_gui_slot_t * slot = gui->slots[ _slot % FD_GUI_SLOTS_CNT ];
    1186             : 
    1187           0 :   char const * level;
    1188           0 :   switch( slot->level ) {
    1189           0 :     case FD_GUI_SLOT_LEVEL_INCOMPLETE:               level = "incomplete"; break;
    1190           0 :     case FD_GUI_SLOT_LEVEL_COMPLETED:                level = "completed";  break;
    1191           0 :     case FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED: level = "optimistically_confirmed"; break;
    1192           0 :     case FD_GUI_SLOT_LEVEL_ROOTED:                   level = "rooted"; break;
    1193           0 :     case FD_GUI_SLOT_LEVEL_FINALIZED:                level = "finalized"; break;
    1194           0 :     default:                                         level = "unknown"; break;
    1195           0 :   }
    1196             : 
    1197           0 :   fd_gui_slot_t * parent_slot = gui->slots[ slot->parent_slot % FD_GUI_SLOTS_CNT ];
    1198           0 :   if( FD_UNLIKELY( parent_slot->slot!=slot->parent_slot ) ) parent_slot = NULL;
    1199             : 
    1200           0 :   long duration_nanos = LONG_MAX;
    1201           0 :   if( FD_LIKELY( slot->completed_time!=LONG_MAX && parent_slot && parent_slot->completed_time!=LONG_MAX ) ) {
    1202           0 :     duration_nanos = slot->completed_time - parent_slot->completed_time;
    1203           0 :   }
    1204             : 
    1205           0 :   jsonp_open_envelope( gui, "slot", "query" );
    1206           0 :     jsonp_ulong( gui, "id", id );
    1207           0 :     jsonp_open_object( gui, "value" );
    1208             : 
    1209           0 :       jsonp_open_object( gui, "publish" );
    1210           0 :         jsonp_ulong( gui, "slot", _slot );
    1211           0 :         jsonp_bool( gui, "mine", slot->mine );
    1212           0 :         jsonp_bool( gui, "skipped", slot->skipped );
    1213           0 :         jsonp_string( gui, "level", level );
    1214           0 :         if( FD_UNLIKELY( duration_nanos==LONG_MAX ) ) jsonp_null( gui, "duration_nanos" );
    1215           0 :         else                                          jsonp_long( gui, "duration_nanos", duration_nanos );
    1216           0 :         if( FD_UNLIKELY( slot->completed_time==LONG_MAX ) ) jsonp_null( gui, "completed_time_nanos" );
    1217           0 :         else                                                jsonp_long( gui, "completed_time_nanos", slot->completed_time );
    1218           0 :         if( FD_UNLIKELY( slot->total_txn_cnt==UINT_MAX
    1219           0 :                          || slot->vote_txn_cnt==UINT_MAX
    1220           0 :                          || slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "success_nonvote_transaction_cnt" );
    1221           0 :         else                                                           jsonp_ulong( gui, "success_nonvote_transaction_cnt", slot->total_txn_cnt - slot->vote_txn_cnt - slot->nonvote_failed_txn_cnt );
    1222           0 :         if( FD_UNLIKELY( slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "failed_nonvote_transaction_cnt" );
    1223           0 :         else                                                        jsonp_ulong( gui, "failed_nonvote_transaction_cnt", slot->nonvote_failed_txn_cnt );
    1224           0 :         if( FD_UNLIKELY( slot->vote_txn_cnt==UINT_MAX
    1225           0 :                          || slot->failed_txn_cnt==UINT_MAX
    1226           0 :                          || slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "success_vote_transaction_cnt" );
    1227           0 :         else                                                           jsonp_ulong( gui, "success_vote_transaction_cnt", slot->vote_txn_cnt - (slot->failed_txn_cnt - slot->nonvote_failed_txn_cnt) );
    1228           0 :         if( FD_UNLIKELY( slot->failed_txn_cnt==UINT_MAX
    1229           0 :                          || slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "failed_vote_transaction_cnt" );
    1230           0 :         else                                                           jsonp_ulong( gui, "failed_vote_transaction_cnt", slot->failed_txn_cnt - slot->nonvote_failed_txn_cnt );
    1231           0 :         if( FD_UNLIKELY( slot->max_compute_units==UINT_MAX ) ) jsonp_null( gui, "max_compute_units" );
    1232           0 :         else                                                       jsonp_ulong( gui, "max_compute_units", slot->max_compute_units );
    1233           0 :         if( FD_UNLIKELY( slot->compute_units==UINT_MAX ) ) jsonp_null( gui, "compute_units" );
    1234           0 :         else                                               jsonp_ulong( gui, "compute_units", slot->compute_units );
    1235           0 :         if( FD_UNLIKELY( slot->transaction_fee==ULONG_MAX ) ) jsonp_null( gui, "transaction_fee" );
    1236           0 :         else                                                  jsonp_ulong( gui, "transaction_fee", slot->transaction_fee );
    1237           0 :         if( FD_UNLIKELY( slot->priority_fee==ULONG_MAX ) ) jsonp_null( gui, "priority_fee" );
    1238           0 :         else                                               jsonp_ulong( gui, "priority_fee", slot->priority_fee );
    1239           0 :         if( FD_UNLIKELY( slot->tips==ULONG_MAX ) ) jsonp_null( gui, "tips" );
    1240           0 :         else                                       jsonp_ulong( gui, "tips", slot->tips );
    1241           0 :       jsonp_close_object( gui );
    1242             : 
    1243           0 :       int overwritten               = (gui->pack_txn_idx - slot->txs.start_offset)>FD_GUI_TXN_HISTORY_SZ;
    1244           0 :       int processed_all_microblocks = slot->slot!=ULONG_MAX &&
    1245           0 :                                       slot->txs.microblocks_upper_bound!=USHORT_MAX &&
    1246           0 :                                       slot->txs.begin_microblocks==slot->txs.end_microblocks &&
    1247           0 :                                       slot->txs.begin_microblocks==slot->txs.microblocks_upper_bound;
    1248             : 
    1249           0 :       if( FD_LIKELY( !overwritten && processed_all_microblocks ) ) {
    1250           0 :         ulong txn_cnt = slot->txs.end_offset-slot->txs.start_offset;
    1251             : 
    1252           0 :         jsonp_open_object( gui, "transactions" );
    1253           0 :           jsonp_long_as_str( gui, "start_timestamp_nanos", slot->txs.leader_start_time );
    1254           0 :           jsonp_long_as_str( gui, "target_end_timestamp_nanos", slot->txs.leader_end_time );
    1255           0 :           jsonp_open_array( gui, "txn_mb_start_timestamps_nanos" );
    1256           0 :             for( ulong i=0UL; i<txn_cnt; i++) jsonp_long_as_str( gui, NULL, slot->txs.reference_nanos + (long)gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->timestamp_delta_start_nanos );
    1257           0 :           jsonp_close_array( gui );
    1258           0 :           jsonp_open_array( gui, "txn_mb_end_timestamps_nanos" );
    1259             :             /* clamp end_ts to start_ts + 1 */
    1260           0 :             for( ulong i=0UL; i<txn_cnt; i++) {
    1261           0 :               jsonp_long_as_str( gui, NULL, slot->txs.reference_nanos + fd_long_max( (long)gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->timestamp_delta_end_nanos,
    1262           0 :                                                                                      (long)gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->timestamp_delta_start_nanos + 1L ) );
    1263           0 :             }
    1264           0 :           jsonp_close_array( gui );
    1265           0 :           jsonp_open_array( gui, "txn_compute_units_requested" );
    1266           0 :             for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong( gui, NULL, gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->compute_units_requested );
    1267           0 :           jsonp_close_array( gui );
    1268           0 :           jsonp_open_array( gui, "txn_compute_units_consumed" );
    1269           0 :             for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong( gui, NULL, gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->compute_units_consumed );
    1270           0 :           jsonp_close_array( gui );
    1271           0 :           jsonp_open_array( gui, "txn_priority_fee" );
    1272           0 :             for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong_as_str( gui, NULL, gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->priority_fee );
    1273           0 :           jsonp_close_array( gui );
    1274           0 :           jsonp_open_array( gui, "txn_transaction_fee" );
    1275           0 :             for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong_as_str( gui, NULL, gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->transaction_fee );
    1276           0 :           jsonp_close_array( gui );
    1277           0 :           jsonp_open_array( gui, "txn_error_code" );
    1278           0 :             for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong( gui, NULL, gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->error_code );
    1279           0 :           jsonp_close_array( gui );
    1280           0 :           jsonp_open_array( gui, "txn_from_bundle" );
    1281           0 :             for( ulong i=0UL; i<txn_cnt; i++) jsonp_bool( gui, NULL, gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->flags & FD_GUI_TXN_FLAGS_FROM_BUNDLE );
    1282           0 :           jsonp_close_array( gui );
    1283           0 :           jsonp_open_array( gui, "txn_is_simple_vote" );
    1284           0 :             for( ulong i=0UL; i<txn_cnt; i++) jsonp_bool( gui, NULL, gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->flags & FD_GUI_TXN_FLAGS_IS_SIMPLE_VOTE );
    1285           0 :           jsonp_close_array( gui );
    1286           0 :           jsonp_open_array( gui, "txn_bank_idx" );
    1287           0 :             for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong( gui, NULL, gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->bank_idx );
    1288           0 :           jsonp_close_array( gui );
    1289           0 :           jsonp_open_array( gui, "txn_preload_end_timestamps_nanos" );
    1290           0 :             for( ulong i=0UL; i<txn_cnt; i++) {
    1291           0 :               fd_gui_txn_t * txn = gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ];
    1292           0 :               long microblock_duration = (long)txn->timestamp_delta_end_nanos - (long)txn->timestamp_delta_start_nanos;
    1293           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);
    1294           0 :               jsonp_long_as_str( gui, NULL, slot->txs.reference_nanos + timestamp_delta_preload_end );
    1295           0 :             }
    1296           0 :           jsonp_close_array( gui );
    1297           0 :           jsonp_open_array( gui, "txn_start_timestamps_nanos" );
    1298           0 :             for( ulong i=0UL; i<txn_cnt; i++) {
    1299           0 :               fd_gui_txn_t * txn = gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ];
    1300           0 :               long microblock_duration = (long)txn->timestamp_delta_end_nanos - (long)txn->timestamp_delta_start_nanos;
    1301           0 :               long timestamp_delta_validate_end = (long)txn->timestamp_delta_start_nanos + (long)((double)txn->txn_start_pct * (double)microblock_duration / (double)UCHAR_MAX);
    1302           0 :               jsonp_long_as_str( gui, NULL, slot->txs.reference_nanos + timestamp_delta_validate_end );
    1303           0 :             }
    1304           0 :           jsonp_close_array( gui );
    1305           0 :           jsonp_open_array( gui, "txn_load_end_timestamps_nanos" );
    1306           0 :             for( ulong i=0UL; i<txn_cnt; i++) {
    1307           0 :               fd_gui_txn_t * txn = gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ];
    1308           0 :               long microblock_duration = (long)txn->timestamp_delta_end_nanos - (long)txn->timestamp_delta_start_nanos;
    1309           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);
    1310           0 :               jsonp_long_as_str( gui, NULL, slot->txs.reference_nanos + timestamp_delta_load_end );
    1311           0 :             }
    1312           0 :           jsonp_close_array( gui );
    1313           0 :           jsonp_open_array( gui, "txn_end_timestamps_nanos" );
    1314           0 :             for( ulong i=0UL; i<txn_cnt; i++) {
    1315           0 :               fd_gui_txn_t * txn = gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ];
    1316           0 :               long microblock_duration = (long)txn->timestamp_delta_end_nanos - (long)txn->timestamp_delta_start_nanos;
    1317           0 :               long timestamp_delta_exec_end = (long)txn->timestamp_delta_start_nanos + (long)((double)txn->txn_end_pct * (double)microblock_duration / (double)UCHAR_MAX);
    1318           0 :               jsonp_long_as_str( gui, NULL, slot->txs.reference_nanos + timestamp_delta_exec_end );
    1319           0 :             }
    1320           0 :           jsonp_close_array( gui );
    1321           0 :           jsonp_open_array( gui, "txn_arrival_timestamps_nanos" );
    1322           0 :             for( ulong i=0UL; i<txn_cnt; i++) jsonp_long_as_str( gui, NULL, gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->timestamp_arrival_nanos );
    1323           0 :           jsonp_close_array( gui );
    1324           0 :           jsonp_open_array( gui, "txn_tips" );
    1325           0 :             for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong_as_str( gui, NULL, gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->tips );
    1326           0 :           jsonp_close_array( gui );
    1327           0 :           jsonp_open_array( gui, "txn_microblock_id" );
    1328           0 :             for( ulong i=0UL; i<txn_cnt; i++) jsonp_ulong( gui, NULL, gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->microblock_idx );
    1329           0 :           jsonp_close_array( gui );
    1330           0 :           jsonp_open_array( gui, "txn_landed" );
    1331           0 :             for( ulong i=0UL; i<txn_cnt; i++) jsonp_bool( gui, NULL, gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->flags & FD_GUI_TXN_FLAGS_LANDED_IN_BLOCK );
    1332           0 :           jsonp_close_array( gui );
    1333           0 :           jsonp_open_array( gui, "txn_signature" );
    1334           0 :             for( ulong i=0UL; i<txn_cnt; i++) {
    1335           0 :               FD_BASE58_ENCODE_64_BYTES( gui->txs[ (slot->txs.start_offset + i)%FD_GUI_TXN_HISTORY_SZ ]->signature, encoded_signature );
    1336           0 :               jsonp_string( gui, NULL, encoded_signature );
    1337           0 :             }
    1338           0 :           jsonp_close_array( gui );
    1339           0 :         jsonp_close_object( gui );
    1340           0 :       } else {
    1341           0 :         jsonp_null( gui, "compute_units" );
    1342           0 :       }
    1343             : 
    1344           0 :     jsonp_close_object( gui );
    1345           0 :   jsonp_close_envelope( gui );
    1346           0 : }
    1347             : 
    1348             : void
    1349             : fd_gui_printf_slot_request_detailed( fd_gui_t * gui,
    1350             :                                      ulong      _slot,
    1351           0 :                                      ulong      id ) {
    1352           0 :   fd_gui_slot_t * slot = gui->slots[ _slot % FD_GUI_SLOTS_CNT ];
    1353             : 
    1354           0 :   char const * level;
    1355           0 :   switch( slot->level ) {
    1356           0 :     case FD_GUI_SLOT_LEVEL_INCOMPLETE:               level = "incomplete"; break;
    1357           0 :     case FD_GUI_SLOT_LEVEL_COMPLETED:                level = "completed";  break;
    1358           0 :     case FD_GUI_SLOT_LEVEL_OPTIMISTICALLY_CONFIRMED: level = "optimistically_confirmed"; break;
    1359           0 :     case FD_GUI_SLOT_LEVEL_ROOTED:                   level = "rooted"; break;
    1360           0 :     case FD_GUI_SLOT_LEVEL_FINALIZED:                level = "finalized"; break;
    1361           0 :     default:                                         level = "unknown"; break;
    1362           0 :   }
    1363             : 
    1364           0 :   fd_gui_slot_t * parent_slot = gui->slots[ slot->parent_slot % FD_GUI_SLOTS_CNT ];
    1365           0 :   if( FD_UNLIKELY( parent_slot->slot!=slot->parent_slot ) ) parent_slot = NULL;
    1366             : 
    1367           0 :   long duration_nanos = LONG_MAX;
    1368           0 :   if( FD_LIKELY( slot->completed_time!=LONG_MAX && parent_slot && parent_slot->completed_time!=LONG_MAX ) ) {
    1369           0 :     duration_nanos = slot->completed_time - parent_slot->completed_time;
    1370           0 :   }
    1371             : 
    1372           0 :   jsonp_open_envelope( gui, "slot", "query" );
    1373           0 :     jsonp_ulong( gui, "id", id );
    1374           0 :     jsonp_open_object( gui, "value" );
    1375             : 
    1376           0 :       jsonp_open_object( gui, "publish" );
    1377           0 :         jsonp_ulong( gui, "slot", _slot );
    1378           0 :         jsonp_bool( gui, "mine", slot->mine );
    1379           0 :         jsonp_bool( gui, "skipped", slot->skipped );
    1380           0 :         jsonp_string( gui, "level", level );
    1381           0 :         if( FD_UNLIKELY( duration_nanos==LONG_MAX ) ) jsonp_null( gui, "duration_nanos" );
    1382           0 :         else                                          jsonp_long( gui, "duration_nanos", duration_nanos );
    1383           0 :         if( FD_UNLIKELY( slot->completed_time==LONG_MAX ) ) jsonp_null( gui, "completed_time_nanos" );
    1384           0 :         else                                                jsonp_long( gui, "completed_time_nanos", slot->completed_time );
    1385           0 :         if( FD_UNLIKELY( slot->total_txn_cnt==UINT_MAX
    1386           0 :                          || slot->vote_txn_cnt==UINT_MAX
    1387           0 :                          || slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "success_nonvote_transaction_cnt" );
    1388           0 :         else                                                           jsonp_ulong( gui, "success_nonvote_transaction_cnt", slot->total_txn_cnt - slot->vote_txn_cnt - slot->nonvote_failed_txn_cnt );
    1389           0 :         if( FD_UNLIKELY( slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "failed_nonvote_transaction_cnt" );
    1390           0 :         else                                                        jsonp_ulong( gui, "failed_nonvote_transaction_cnt", slot->nonvote_failed_txn_cnt );
    1391           0 :         if( FD_UNLIKELY( slot->vote_txn_cnt==UINT_MAX
    1392           0 :                          || slot->failed_txn_cnt==UINT_MAX
    1393           0 :                          || slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "success_vote_transaction_cnt" );
    1394           0 :         else                                                           jsonp_ulong( gui, "success_vote_transaction_cnt", slot->vote_txn_cnt - (slot->failed_txn_cnt - slot->nonvote_failed_txn_cnt) );
    1395           0 :         if( FD_UNLIKELY( slot->failed_txn_cnt==UINT_MAX
    1396           0 :                          || slot->nonvote_failed_txn_cnt==UINT_MAX ) ) jsonp_null( gui, "failed_vote_transaction_cnt" );
    1397           0 :         else                                                           jsonp_ulong( gui, "failed_vote_transaction_cnt", slot->failed_txn_cnt - slot->nonvote_failed_txn_cnt );
    1398           0 :         if( FD_UNLIKELY( slot->max_compute_units==UINT_MAX ) ) jsonp_null( gui, "max_compute_units" );
    1399           0 :         else                                                   jsonp_ulong( gui, "max_compute_units", slot->max_compute_units );
    1400           0 :         if( FD_UNLIKELY( slot->compute_units==UINT_MAX ) ) jsonp_null( gui, "compute_units" );
    1401           0 :         else                                               jsonp_ulong( gui, "compute_units", slot->compute_units );
    1402           0 :         if( FD_UNLIKELY( slot->transaction_fee==ULONG_MAX ) ) jsonp_null( gui, "transaction_fee" );
    1403           0 :         else                                                  jsonp_ulong( gui, "transaction_fee", slot->transaction_fee );
    1404           0 :         if( FD_UNLIKELY( slot->priority_fee==ULONG_MAX ) ) jsonp_null( gui, "priority_fee" );
    1405           0 :         else                                               jsonp_ulong( gui, "priority_fee", slot->priority_fee );
    1406           0 :         if( FD_UNLIKELY( slot->tips==ULONG_MAX ) ) jsonp_null( gui, "tips" );
    1407           0 :         else                                       jsonp_ulong( gui, "tips", slot->tips );
    1408           0 :       jsonp_close_object( gui );
    1409             : 
    1410           0 :       if( FD_LIKELY( slot->leader_state==FD_GUI_SLOT_LEADER_ENDED ) ) {
    1411           0 :         fd_gui_printf_waterfall( gui, slot->waterfall_begin, slot->waterfall_end );
    1412             : 
    1413           0 :         if( FD_LIKELY( gui->summary.tile_timers_leader_history_slot[ slot->tile_timers_history_idx ]==_slot ) ) {
    1414           0 :           jsonp_open_array( gui, "tile_timers" );
    1415           0 :             fd_gui_tile_timers_t const * prev_timer = gui->summary.tile_timers_leader_history[ slot->tile_timers_history_idx ][ 0 ];
    1416           0 :             for( ulong i=1UL; i<gui->summary.tile_timers_leader_history_slot_sample_cnt[ slot->tile_timers_history_idx ]; i++ ) {
    1417           0 :               fd_gui_tile_timers_t const * cur_timer = gui->summary.tile_timers_leader_history[ slot->tile_timers_history_idx ][ i ];
    1418           0 :               fd_gui_printf_ts_tile_timers( gui, prev_timer, cur_timer );
    1419           0 :               prev_timer = cur_timer;
    1420           0 :             }
    1421           0 :           jsonp_close_array( gui );
    1422           0 :         } else {
    1423             :           /* Our tile timers were overwritten. */
    1424           0 :           jsonp_null( gui, "tile_timers" );
    1425           0 :         }
    1426             : 
    1427           0 :         fd_gui_printf_tile_stats( gui, slot->tile_stats_begin, slot->tile_stats_end );
    1428           0 :       } else {
    1429           0 :         jsonp_null( gui, "waterfall" );
    1430           0 :         jsonp_null( gui, "tile_timers" );
    1431           0 :         jsonp_null( gui, "tile_primary_metric" );
    1432           0 :       }
    1433             : 
    1434           0 :     jsonp_close_object( gui );
    1435           0 :   jsonp_close_envelope( gui );
    1436           0 : }

Generated by: LCOV version 1.14