MCPcopy Create free account
hub / github.com/Commit-Boost/commit-boost-client / run

Method run

crates/signer/src/service.rs:77–130  ·  view source on GitHub ↗
(config: StartSignerConfig)

Source from the content-addressed store, hash-verified

75
76impl SigningService {
77 pub async fn run(config: StartSignerConfig) -> eyre::Result<()> {
78 if config.jwts.is_empty() {
79 warn!("Signing service was started but no module is registered. Exiting");
80 return Ok(());
81 }
82
83 let module_ids: Vec<String> = config.jwts.keys().cloned().map(Into::into).collect();
84
85 let state = SigningState {
86 manager: Arc::new(RwLock::new(start_manager(config.clone()).await?)),
87 jwts: config.jwts.into(),
88 jwt_auth_failures: Arc::new(ParkingRwLock::new(HashMap::new())),
89 jwt_auth_fail_limit: config.jwt_auth_fail_limit,
90 jwt_auth_fail_timeout: Duration::from_secs(config.jwt_auth_fail_timeout_seconds as u64),
91 };
92
93 // Get the signer counts
94 let loaded_consensus: usize;
95 let loaded_proxies: usize;
96 {
97 let manager = state.manager.read().await;
98 loaded_consensus = manager.available_consensus_signers();
99 loaded_proxies = manager.available_proxy_signers();
100 }
101
102 info!(
103 version = COMMIT_BOOST_VERSION,
104 commit_hash = COMMIT_BOOST_COMMIT,
105 modules =? module_ids,
106 endpoint =? config.endpoint,
107 loaded_consensus,
108 loaded_proxies,
109 jwt_auth_fail_limit =? state.jwt_auth_fail_limit,
110 jwt_auth_fail_timeout =? state.jwt_auth_fail_timeout,
111 "Starting signing service"
112 );
113
114 SigningService::init_metrics(config.chain)?;
115
116 let app = axum::Router::new()
117 .route(REQUEST_SIGNATURE_PATH, post(handle_request_signature))
118 .route(GET_PUBKEYS_PATH, get(handle_get_pubkeys))
119 .route(GENERATE_PROXY_KEY_PATH, post(handle_generate_proxy))
120 .route_layer(middleware::from_fn_with_state(state.clone(), jwt_auth))
121 .route(RELOAD_PATH, post(handle_reload))
122 .with_state(state.clone())
123 .route_layer(middleware::from_fn(log_request))
124 .route(STATUS_PATH, get(handle_status))
125 .into_make_service_with_connect_info::<SocketAddr>();
126
127 let listener = TcpListener::bind(config.endpoint).await?;
128
129 axum::serve(listener, app).await.wrap_err("signer server exited")
130 }
131
132 fn init_metrics(network: Chain) -> eyre::Result<()> {
133 MetricsProvider::load_and_run(network, SIGNER_METRICS_REGISTRY.clone())

Callers 2

jwt_authFunction · 0.45
log_requestFunction · 0.45

Calls 3

start_managerFunction · 0.85

Tested by

no test coverage detected