Skip to content

Commit 98180a0

Browse files
authored
fix(pyth-lazer-agent): add back optional authorization_key
2 parents d5d48bc + b80ca8a commit 98180a0

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

apps/pyth-lazer-agent/Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/pyth-lazer-agent/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyth-lazer-agent"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2024"
55

66
[dependencies]

apps/pyth-lazer-agent/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use url::Url;
1212
pub struct Config {
1313
pub listen_address: SocketAddr,
1414
pub relayer_urls: Vec<Url>,
15+
pub authorization_token: Option<String>,
1516
#[derivative(Debug = "ignore")]
1617
pub publish_keypair_path: PathBuf,
1718
#[serde(with = "humantime_serde", default = "default_publish_interval")]

apps/pyth-lazer-agent/src/lazer_publisher.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,20 @@ impl LazerPublisher {
5656
}
5757
};
5858

59+
let authorization_token =
60+
if let Some(authorization_token) = config.authorization_token.clone() {
61+
// If authorization_token is configured, use it.
62+
authorization_token
63+
} else {
64+
// Otherwise, use the base64 pubkey.
65+
BASE64_STANDARD.encode(signing_key.verifying_key().to_bytes())
66+
};
67+
5968
let (relayer_sender, _) = broadcast::channel(CHANNEL_CAPACITY);
6069
for url in config.relayer_urls.iter() {
6170
let mut task = RelayerSessionTask {
6271
url: url.clone(),
63-
token: BASE64_STANDARD.encode(signing_key.verifying_key().to_bytes()),
72+
token: authorization_token.clone(),
6473
receiver: relayer_sender.subscribe(),
6574
};
6675
tokio::spawn(async move { task.run().await });
@@ -203,6 +212,7 @@ mod tests {
203212
let config = Config {
204213
listen_address: "0.0.0.0:12345".parse().unwrap(),
205214
relayer_urls: vec![Url::parse("http://127.0.0.1:12346").unwrap()],
215+
authorization_token: None,
206216
publish_keypair_path: PathBuf::from(signing_key_file.path()),
207217
publish_interval_duration: Duration::from_millis(25),
208218
};

0 commit comments

Comments
 (0)