Skip to content

Commit 5f1c00b

Browse files
committed
added UserAgent to referral and points
1 parent dac27f1 commit 5f1c00b

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "dkn-compute-launcher"
33
edition = "2021"
4-
version = "0.1.12"
4+
version = "0.1.13"
55
license = "Apache-2.0"
66
readme = "README.md"
77
description = "Dria Compute Node Launcher"

src/commands/points.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use eyre::Context;
22

3-
use crate::utils::DriaEnv;
3+
use crate::utils::{DriaEnv, LAUNCHER_USER_AGENT};
44

55
const POINTS_API_BASE_URL: &str =
66
"https://mainnet.dkn.dria.co/dashboard/supply/v0/leaderboard/steps";
@@ -31,10 +31,16 @@ pub async fn show_points() -> eyre::Result<()> {
3131
address.trim_start_matches("0x")
3232
);
3333

34-
let res = reqwest::get(&url)
34+
let client = reqwest::Client::builder()
35+
.user_agent(LAUNCHER_USER_AGENT)
36+
.build()
37+
.wrap_err("could not create reqwest client")?;
38+
39+
let res = client
40+
.get(&url)
41+
.send()
3542
.await
3643
.wrap_err("could not make request")?;
37-
// println!("Response: {:?}", res.text().await);
3844

3945
let points = res
4046
.json::<PointsRes>()

src/utils/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,7 @@ pub const PROGRESS_BAR_TEMPLATE: &str =
4444

4545
/// Progress bar characters for download progress.
4646
pub const PROGRESS_BAR_CHARS: &str = "=>-";
47+
48+
/// `UserAgent` header value for the launcher, used for HTTP requests.
49+
pub const LAUNCHER_USER_AGENT: &str =
50+
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));

src/utils/referrals.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use eyre::{eyre, Context, Result};
22
use libsecp256k1::SecretKey;
3-
use reqwest::Client;
43

54
use crate::utils::crypto::eip191_hash;
65

7-
const REFERRALS_API_BASE_URL: &str = "https://dkn.dria.co/referral/v0";
8-
// const REFERRALS_API_BASE_URL: &str = "http://localhost:8080/referral/v0";
6+
use super::LAUNCHER_USER_AGENT;
7+
8+
const REFERRALS_API_BASE_URL: &str = "https://mainnet.dkn.dria.co/referrals/v0/";
99

1010
pub struct ReferralsClient {
1111
base_url: String,
@@ -20,9 +20,14 @@ impl Default for ReferralsClient {
2020

2121
impl ReferralsClient {
2222
pub fn new(base_url: &str) -> Self {
23+
let client = reqwest::Client::builder()
24+
.user_agent(LAUNCHER_USER_AGENT)
25+
.build()
26+
.expect("could not create reqwest client");
27+
2328
Self {
2429
base_url: base_url.to_string(),
25-
client: Client::new(),
30+
client,
2631
}
2732
}
2833

0 commit comments

Comments
 (0)