Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/pyth-lazer-agent/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/pyth-lazer-agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyth-lazer-agent"
version = "0.1.0"
version = "0.1.1"
edition = "2024"

[dependencies]
Expand Down
1 change: 1 addition & 0 deletions apps/pyth-lazer-agent/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use url::Url;
pub struct Config {
pub listen_address: SocketAddr,
pub relayer_urls: Vec<Url>,
pub authorization_token: Option<String>,
#[derivative(Debug = "ignore")]
pub publish_keypair_path: PathBuf,
#[serde(with = "humantime_serde", default = "default_publish_interval")]
Expand Down
12 changes: 11 additions & 1 deletion apps/pyth-lazer-agent/src/lazer_publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,20 @@ impl LazerPublisher {
}
};

let authorization_token =
if let Some(authorization_token) = config.authorization_token.clone() {
// If authorization_token is configured, use it.
authorization_token
} else {
// Otherwise, use the base64 pubkey.
BASE64_STANDARD.encode(signing_key.verifying_key().to_bytes())
};

let (relayer_sender, _) = broadcast::channel(CHANNEL_CAPACITY);
for url in config.relayer_urls.iter() {
let mut task = RelayerSessionTask {
url: url.clone(),
token: BASE64_STANDARD.encode(signing_key.verifying_key().to_bytes()),
token: authorization_token.clone(),
receiver: relayer_sender.subscribe(),
};
tokio::spawn(async move { task.run().await });
Expand Down Expand Up @@ -203,6 +212,7 @@ mod tests {
let config = Config {
listen_address: "0.0.0.0:12345".parse().unwrap(),
relayer_urls: vec![Url::parse("http://127.0.0.1:12346").unwrap()],
authorization_token: None,
publish_keypair_path: PathBuf::from(signing_key_file.path()),
publish_interval_duration: Duration::from_millis(25),
};
Expand Down