Line data Source code
1 : #ifndef CORE_SUBTOPO_H 2 : #define CORE_SUBTOPO_H 3 : 4 : #include "../../shared/fd_config.h" 5 : #include "../../../disco/topo/fd_topob.h" 6 : #include "../../../disco/net/fd_net_tile.h" /* fd_topos_net_tiles */ 7 : 8 : extern fd_topo_obj_callbacks_t * CALLBACKS[]; 9 : 10 : /* core_subtopo creates the 'core' subtopo: net, metrics, and sign tiles. 11 : and the links between them. 12 : Other tiles and links can be attached to these after it returns. 13 : Therefore, it does not call finish (neither net nor topo ) 14 : 15 : ALL SUBTOPOS should be disjoint! */ 16 : FD_FN_UNUSED static void 17 0 : fd_core_subtopo( config_t * config, ulong tile_to_cpu[ FD_TILE_MAX ] ) { 18 0 : fd_topo_t * topo = &config->topo; 19 : 20 0 : static char* const tiles_to_add[] = { 21 0 : "metric", 22 0 : "net", 23 0 : "sign", 24 0 : }; 25 0 : for( int i=0; i<3; ++i) FD_TEST( fd_topo_find_tile( topo, tiles_to_add[i], 0UL ) == ULONG_MAX ); 26 : 27 0 : ulong net_tile_cnt = config->layout.net_tile_count; 28 0 : ulong sign_tile_cnt = config->firedancer.layout.sign_tile_count; 29 : 30 0 : fd_topob_wksp( topo, "metric" ); 31 0 : fd_topob_wksp( topo, "metric_in" ); 32 0 : fd_topo_tile_t * metric_tile = fd_topob_tile( topo, "metric", "metric", "metric_in", ULONG_MAX, 0, 0 ); 33 0 : if( FD_UNLIKELY( !fd_cstr_to_ip4_addr( config->tiles.metric.prometheus_listen_address, &metric_tile->metric.prometheus_listen_addr ) ) ) 34 0 : FD_LOG_ERR(( "failed to parse prometheus listen address `%s`", config->tiles.metric.prometheus_listen_address )); 35 0 : metric_tile->metric.prometheus_listen_port = config->tiles.metric.prometheus_listen_port; 36 : 37 0 : fd_topos_net_tiles( topo, net_tile_cnt, &config->net, config->tiles.netlink.max_routes, config->tiles.netlink.max_peer_routes, config->tiles.netlink.max_neighbors, tile_to_cpu ); 38 0 : ulong net_tile_id = fd_topo_find_tile( topo, "net", 0UL ); 39 0 : if( net_tile_id==ULONG_MAX ) net_tile_id = fd_topo_find_tile( topo, "sock", 0UL ); 40 0 : if( FD_UNLIKELY( net_tile_id==ULONG_MAX ) ) FD_LOG_ERR(( "net tile not found" )); 41 0 : fd_topo_tile_t * net_tile = &topo->tiles[ net_tile_id ]; 42 0 : net_tile->net.gossip_listen_port = config->gossip.port; 43 : 44 0 : fd_topob_wksp( topo, "sign" ); 45 0 : for( ulong i=0UL; i<sign_tile_cnt; i++ ) { 46 0 : fd_topo_tile_t * sign_tile = fd_topob_tile( topo, "sign", "sign", "metric_in", tile_to_cpu[ topo->tile_cnt ], 0, 1 ); 47 0 : strncpy( sign_tile->sign.identity_key_path, config->paths.identity_key, sizeof(sign_tile->sign.identity_key_path) ); 48 0 : } 49 0 : } 50 : 51 : 52 : /* Use fd_link_permit_no_producers with links that do not have any 53 : producers. This may be required in sub-topologies used for 54 : development and testing. */ 55 : FD_FN_UNUSED static ulong 56 0 : fd_link_permit_no_producers( fd_topo_t * topo, char * link_name ) { 57 0 : ulong found = 0UL; 58 0 : for( ulong link_i = 0UL; link_i < topo->link_cnt; link_i++ ) { 59 0 : if( !strcmp( topo->links[ link_i ].name, link_name ) ) { 60 0 : topo->links[ link_i ].permit_no_producers = 1; 61 0 : found++; 62 0 : } 63 0 : } 64 0 : return found; 65 0 : } 66 : 67 : /* Use fd_link_permit_no_consumers with links that do not have any 68 : consumers. This may be required in sub-topologies used for 69 : development and testing. */ 70 : FD_FN_UNUSED static ulong 71 0 : fd_link_permit_no_consumers( fd_topo_t * topo, char * link_name ) { 72 0 : ulong found = 0UL; 73 0 : for( ulong link_i = 0UL; link_i < topo->link_cnt; link_i++ ) { 74 0 : if( !strcmp( topo->links[ link_i ].name, link_name ) ) { 75 0 : topo->links[ link_i ].permit_no_consumers = 1; 76 0 : found++; 77 0 : } 78 0 : } 79 0 : return found; 80 0 : } 81 : 82 : #endif /* CORE_SUBTOPO_H */