mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 04:09:23 +00:00
MessageQueue::new
This commit is contained in:
@@ -26,11 +26,14 @@ pub struct MessageQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MessageQueue {
|
impl MessageQueue {
|
||||||
pub fn from_env(service: Service) -> MessageQueue {
|
pub fn new(
|
||||||
|
service: Service,
|
||||||
|
mut url: String,
|
||||||
|
priv_key: Zeroizing<<Ristretto as Ciphersuite>::F>,
|
||||||
|
) -> MessageQueue {
|
||||||
// Allow MESSAGE_QUEUE_RPC to either be a full URL or just a hostname
|
// Allow MESSAGE_QUEUE_RPC to either be a full URL or just a hostname
|
||||||
// While we could stitch together multiple env variables, our control over this service makes
|
// While we could stitch together multiple variables, our control over this service makes this
|
||||||
// this fine
|
// fine
|
||||||
let mut url = env::var("MESSAGE_QUEUE_RPC").expect("message-queue RPC wasn't specified");
|
|
||||||
if !url.contains(':') {
|
if !url.contains(':') {
|
||||||
url += ":2287";
|
url += ":2287";
|
||||||
}
|
}
|
||||||
@@ -38,6 +41,18 @@ impl MessageQueue {
|
|||||||
url = "http://".to_string() + &url;
|
url = "http://".to_string() + &url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageQueue {
|
||||||
|
service,
|
||||||
|
pub_key: Ristretto::generator() * priv_key.deref(),
|
||||||
|
priv_key,
|
||||||
|
client: Client::new(),
|
||||||
|
url,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn from_env(service: Service) -> MessageQueue {
|
||||||
|
let url = env::var("MESSAGE_QUEUE_RPC").expect("message-queue RPC wasn't specified");
|
||||||
|
|
||||||
let priv_key: Zeroizing<<Ristretto as Ciphersuite>::F> = {
|
let priv_key: Zeroizing<<Ristretto as Ciphersuite>::F> = {
|
||||||
let key_str =
|
let key_str =
|
||||||
Zeroizing::new(env::var("MESSAGE_QUEUE_KEY").expect("message-queue key wasn't specified"));
|
Zeroizing::new(env::var("MESSAGE_QUEUE_KEY").expect("message-queue key wasn't specified"));
|
||||||
@@ -54,13 +69,7 @@ impl MessageQueue {
|
|||||||
key
|
key
|
||||||
};
|
};
|
||||||
|
|
||||||
MessageQueue {
|
Self::new(service, url, priv_key)
|
||||||
service,
|
|
||||||
pub_key: Ristretto::generator() * priv_key.deref(),
|
|
||||||
priv_key,
|
|
||||||
client: Client::new(),
|
|
||||||
url,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn json_call(&self, method: &'static str, params: serde_json::Value) -> serde_json::Value {
|
async fn json_call(&self, method: &'static str, params: serde_json::Value) -> serde_json::Value {
|
||||||
|
|||||||
Reference in New Issue
Block a user