dfinity / agent-rs

A collection of libraries and tools for building software around the Internet Computer, in Rust.
https://sdk.dfinity.org/
Apache License 2.0
124 stars 77 forks source link

feat: generate a file with a list of API seeds at compile time #578

Closed nikolay-komarevskiy closed 3 months ago

nikolay-komarevskiy commented 3 months ago

Description

Using the build script approach (build.rs), we auto-generate an api_seed_nodes.rs file, containing a full list of existing API nodes. This generation is done at compile time. The generated api_seed_nodes.rs file is further used as a seed-list input for building an agent with discovery service.

This is how the generated api_seed_nodes.rs file looks like:

#[allow(dead_code)]
const API_SEED_NODES: &[&str] = &[
    "dll02.sg2.icp.162.technology",
    "bc1-dll02.blockchaindevlabs.com",
    "br1-dll01.aviatelabs.co",
];

How Has This Been Tested?

Tested manually by running:

#[tokio::main]
async fn main() {
    let client = Client::builder().build().expect("failed to build a client");
    let agent = Agent::builder()
        .with_discovery_transport(client)
        .await
        .build()
        .expect("failed to create an agent");

    // use agent for query, update calls.
}

Checklist: