Skip to content

Commit

Permalink
chore: set root_key for NodesFetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolay-komarevskiy committed Jul 30, 2024
1 parent ad521f4 commit af770c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ impl<S> DynamicRouteProviderBuilder<S> {
let fetcher = Arc::new(NodesFetcher::new(
http_client.clone(),
Principal::from_text(MAINNET_ROOT_SUBNET_ID).unwrap(),
None,
));
let checker = Arc::new(HealthChecker::new(http_client, HEALTH_CHECK_TIMEOUT));
Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@ pub trait Fetch: Sync + Send + Debug {
pub struct NodesFetcher {
http_client: Client,
subnet_id: Principal,
// By default, the nodes fetcher is configured to talk to the mainnet of Internet Computer, and verifies responses using a hard-coded public key.
// However, for testnets one can set up a custom public key.
root_key: Option<Vec<u8>>,
}

impl NodesFetcher {
/// Creates a new `NodesFetcher` instance.
pub fn new(http_client: Client, subnet_id: Principal) -> Self {
pub fn new(http_client: Client, subnet_id: Principal, root_key: Option<Vec<u8>>) -> Self {
Self {
http_client,
subnet_id,
root_key,
}
}
}
Expand All @@ -65,6 +69,9 @@ impl Fetch for NodesFetcher {
"Failed to build the agent: {err}"
))
})?;
if let Some(key) = self.root_key.clone() {
agent.set_root_key(key);
}
let api_bns = agent
.fetch_api_boundary_nodes_by_subnet_id(self.subnet_id)
.await
Expand Down

0 comments on commit af770c1

Please sign in to comment.