Skip to content

Commit f2281aa

Browse files
committed
testnet points api
1 parent d021b2c commit f2281aa

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

compute/src/node/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl DriaComputeNode {
122122
};
123123

124124
let model_names = config.executors.get_model_names();
125-
let points_client = DriaPointsClient::new(&config.address)?;
125+
let points_client = DriaPointsClient::new(&config.address, &config.network)?;
126126

127127
let spec_collector = SpecCollector::new(model_names.clone(), config.version);
128128
Ok((

compute/src/utils/points.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
use dkn_utils::DriaNetwork;
12
use eyre::Context;
23

3-
const POINTS_API_BASE_URL: &str = "https://mainnet.dkn.dria.co/points/v0/total/node/";
4-
54
pub struct DriaPointsClient {
65
pub url: String,
76
client: reqwest::Client,
@@ -18,13 +17,21 @@ pub struct DriaPoints {
1817
}
1918

2019
impl DriaPointsClient {
20+
/// The base URL for the points API, w.r.t network.
21+
pub fn base_url(network: &DriaNetwork) -> &'static str {
22+
match network {
23+
DriaNetwork::Mainnet => "https://mainnet.dkn.dria.co/points/v0/total/node/",
24+
DriaNetwork::Testnet => "https://testnet.dkn.dria.co/points/v0/total/node/",
25+
}
26+
}
27+
2128
/// Creates a new `DriaPointsClient` for the given address.
22-
pub fn new(address: &str) -> eyre::Result<Self> {
29+
pub fn new(address: &str, network: &DriaNetwork) -> eyre::Result<Self> {
2330
const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
2431

2532
let url = format!(
2633
"{}/0x{}",
27-
POINTS_API_BASE_URL,
34+
Self::base_url(network),
2835
address.trim_start_matches("0x")
2936
);
3037

@@ -66,7 +73,11 @@ mod tests {
6673

6774
#[tokio::test]
6875
async fn test_get_points() {
69-
let client = DriaPointsClient::new("0xa43536a6032a3907ccf60e8109429ee1047b207c").unwrap();
76+
let client = DriaPointsClient::new(
77+
"0xa43536a6032a3907ccf60e8109429ee1047b207c",
78+
&DriaNetwork::Mainnet,
79+
)
80+
.unwrap();
7081
let steps = client.get_points().await.unwrap();
7182
assert!(steps.score >= 0.0);
7283
assert!(steps.percentile <= 100);

0 commit comments

Comments
 (0)