@@ -162,6 +162,8 @@ fd_gui_peers_new( void * shmem,
162162 ctx -> open_ws_conn_cnt = 0UL ;
163163 ctx -> active_ws_conn_id = ULONG_MAX ;
164164
165+ ctx -> published_peers_sz = 0UL ;
166+
165167 ctx -> slot_voted = ULONG_MAX ;
166168
167169 ctx -> next_client_nanos = now ;
@@ -612,9 +614,9 @@ fd_gui_peers_handle_gossip_update( fd_gui_peers_ctx_t * peers,
612614 fd_gui_peers_live_table_idx_insert ( peers -> live_table , update -> contact_info .idx , peers -> contact_info_table );
613615 fd_gui_peers_node_sock_map_idx_insert ( peers -> node_sock_map , update -> contact_info .idx , peers -> contact_info_table );
614616
615- /* broadcast update to WebSocket clients */
616- fd_gui_peers_printf_nodes ( peers , (int []){ FD_GUI_PEERS_NODE_UPDATE }, (ulong []){ update -> contact_info .idx }, 1UL );
617- fd_http_server_ws_broadcast ( peers -> http );
617+ // / * broadcast update to WebSocket clients */
618+ // fd_gui_peers_printf_nodes( peers, (int[]){ FD_GUI_PEERS_NODE_UPDATE }, (ulong[]){ update->contact_info.idx }, 1UL );
619+ // fd_http_server_ws_broadcast( peers->http );
618620 } else {
619621 FD_TEST ( !fd_gui_peers_node_pubkey_map_ele_query_const ( peers -> node_pubkey_map , & update -> contact_info .contact_info -> pubkey , NULL , peers -> contact_info_table ) );
620622#if LOGGING
@@ -655,9 +657,17 @@ fd_gui_peers_handle_gossip_update( fd_gui_peers_ctx_t * peers,
655657 fd_gui_printf_peers_view_resize ( peers , fd_gui_peers_live_table_ele_cnt ( peers -> live_table ) );
656658 fd_http_server_ws_broadcast ( peers -> http );
657659
658- /* broadcast update to WebSocket clients */
659- fd_gui_peers_printf_nodes ( peers , (int []){ FD_GUI_PEERS_NODE_ADD }, (ulong []){ update -> contact_info .idx }, 1UL );
660- fd_http_server_ws_broadcast ( peers -> http );
660+ ulong pubkey_hash = fd_hash ( 42UL , update -> contact_info .contact_info -> pubkey .uc , sizeof (fd_pubkey_t ) );
661+ if ( FD_UNLIKELY ( !peers -> published_peers_sz || pubkey_hash != peers -> published_peers [ fd_sort_up_ulong_split ( peers -> published_peers , peers -> published_peers_sz , pubkey_hash ) ] ) ) {
662+ if ( FD_LIKELY ( peers -> published_peers_sz < FD_CONTACT_INFO_TABLE_SIZE ) ) {
663+ peers -> published_peers [ peers -> published_peers_sz ++ ] = pubkey_hash ;
664+ fd_sort_up_ulong_insert ( peers -> published_peers , peers -> published_peers_sz );
665+
666+ /* broadcast update to WebSocket clients, only one time */
667+ fd_gui_peers_printf_nodes ( peers , (int []){ FD_GUI_PEERS_NODE_ADD }, (ulong []){ update -> contact_info .idx }, 1UL );
668+ fd_http_server_ws_broadcast ( peers -> http );
669+ }
670+ }
661671 }
662672 break ;
663673 }
@@ -694,9 +704,9 @@ fd_gui_peers_handle_gossip_update( fd_gui_peers_ctx_t * peers,
694704 fd_gui_printf_peers_view_resize ( peers , fd_gui_peers_live_table_ele_cnt ( peers -> live_table ) );
695705 fd_http_server_ws_broadcast ( peers -> http );
696706
697- /* broadcast update to WebSocket clients */
698- fd_gui_peers_printf_nodes ( peers , (int []){ FD_GUI_PEERS_NODE_DELETE }, (ulong []){ update -> contact_info_remove .idx }, 1UL );
699- fd_http_server_ws_broadcast ( peers -> http );
707+ // / * broadcast update to WebSocket clients */
708+ // fd_gui_peers_printf_nodes( peers, (int[]){ FD_GUI_PEERS_NODE_DELETE }, (ulong[]){ update->contact_info_remove.idx }, 1UL );
709+ // fd_http_server_ws_broadcast( peers->http );
700710 break ;
701711 }
702712 default : break ;
@@ -789,6 +799,10 @@ fd_gui_peers_handle_vote_update( fd_gui_peers_ctx_t * peers,
789799
790800 fd_gui_peers_node_t * peer = peers -> contact_info_table + peer_idx ;
791801
802+ /* Shard vote updates over a 10 second period. This prevents a huge
803+ spike in stake updates the first time during startup. */
804+ if ( FD_LIKELY ( (((ulong )now % (ulong )(10UL * 1e9 )) / (ulong )1e9 ) != (peer_idx % 10 ) ) ) continue ;
805+
792806 /* TODO: we only publish updates when stake changes, otherwise we'd
793807 have to republish for every peer every slot, which ends up being
794808 too much bandwidth because we republish all the peer info.
0 commit comments