v0.3.7-pre.006
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// file: crates/ksp-app-backfill-desk/src/transport_runtime.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
//! Composite-selected HTTP Transport readiness owned by Backfill Desk.
|
||||
//! Composite-selected HTTP Transport readiness and route inventory owned by Backfill Desk.
|
||||
|
||||
/// Safe and executable Transport runtime retained by the application state.
|
||||
pub(crate) struct TransportRuntime {
|
||||
@@ -30,16 +30,16 @@ impl TransportRuntime {
|
||||
pub(crate) fn options(&self) -> ksp_core_lib::Result<crate::BackfillDeskOptionsDto> {
|
||||
let snapshot = self.pool.snapshot();
|
||||
let configured_networks = configured_networks(&snapshot);
|
||||
let compatible_roles = compatible_backfill_roles(&self.pool, &snapshot);
|
||||
let compatible_roles = match compatible_roles {
|
||||
let http_routes = compatible_backfill_http_routes(&self.pool, &snapshot);
|
||||
let http_routes = match http_routes {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error),
|
||||
};
|
||||
let transport_ready = configured_networks.len() == 1 && !compatible_roles.is_empty() && snapshot.available_endpoint_count() > 0;
|
||||
let transport_ready = configured_networks.len() == 1 && !http_routes.is_empty() && snapshot.available_endpoint_count() > 0;
|
||||
return std::result::Result::Ok(crate::BackfillDeskOptionsDto {
|
||||
compatible_roles,
|
||||
composition_ready: false,
|
||||
configured_networks,
|
||||
http_routes,
|
||||
network_coherent: false,
|
||||
store_diagnostic: std::option::Option::None,
|
||||
store_network: std::option::Option::None,
|
||||
@@ -89,17 +89,17 @@ pub(crate) fn initialize_transport(management: &ksp_config_lib::ConfigManagement
|
||||
domain = crate::TRACING_DOMAIN_TRANSPORT,
|
||||
transport_profile = runtime.profile_id(),
|
||||
network_count = options.configured_networks.len(),
|
||||
compatible_role_count = options.compatible_roles.len(),
|
||||
http_route_count = options.http_routes.len(),
|
||||
transport_ready = options.transport_ready,
|
||||
"initialized Backfill Desk HTTP Transport readiness from composite-managed configuration"
|
||||
);
|
||||
return std::result::Result::Ok(runtime);
|
||||
}
|
||||
|
||||
fn compatible_backfill_roles(
|
||||
fn compatible_backfill_http_routes(
|
||||
pool: &ksp_onchain_transport_lib::HttpTransportPool,
|
||||
snapshot: &ksp_onchain_transport_lib::HttpTransportPoolSnapshot,
|
||||
) -> ksp_core_lib::Result<std::vec::Vec<String>> {
|
||||
) -> ksp_core_lib::Result<std::vec::Vec<crate::BackfillHttpRouteOptionDto>> {
|
||||
let signatures = required_http_rpc_method("getSignaturesForAddress");
|
||||
let signatures = match signatures {
|
||||
std::result::Result::Ok(value) => value,
|
||||
@@ -110,22 +110,23 @@ fn compatible_backfill_roles(
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error),
|
||||
};
|
||||
let mut candidates = std::collections::BTreeSet::new();
|
||||
let mut candidates = std::collections::BTreeMap::<String, std::collections::BTreeSet<String>>::new();
|
||||
for endpoint in snapshot.endpoints() {
|
||||
if !endpoint.enabled() {
|
||||
continue;
|
||||
}
|
||||
for role in endpoint.roles() {
|
||||
if role.enabled() {
|
||||
candidates.insert(role.role().to_owned());
|
||||
candidates.entry(role.role().to_owned()).or_default().insert(endpoint.provider().to_owned());
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut compatible = std::vec::Vec::new();
|
||||
for candidate in candidates {
|
||||
for (candidate, providers) in candidates {
|
||||
let role = ksp_onchain_transport_lib::HttpRoleName::new(candidate.clone());
|
||||
if pool.select_for_method(&role, signatures).is_ok() && pool.select_for_method(&role, transaction).is_ok() {
|
||||
compatible.push(candidate);
|
||||
let providers = providers.into_iter().collect::<std::vec::Vec<_>>();
|
||||
compatible.push(crate::BackfillHttpRouteOptionDto { pooled: providers.len() > 1, providers, role: candidate });
|
||||
}
|
||||
}
|
||||
return std::result::Result::Ok(compatible);
|
||||
|
||||
Reference in New Issue
Block a user