Improves brain connection reliability
Updates the brain connection logic to randomly select from a list of available URLs for staging and testnet environments.
This commit is contained in:
parent
4648d08646
commit
dde2d88dde
@ -3,20 +3,43 @@
|
||||
use anyhow::Result;
|
||||
use ed25519_dalek::SigningKey;
|
||||
use log::{info, warn};
|
||||
use rand::Rng;
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::sync::LazyLock;
|
||||
|
||||
pub const DETEE_ROOT_CA: &str = "/etc/detee/root_ca.pem";
|
||||
pub const BRAIN_STAGING: (&str, &str) = ("https://159.65.58.38:31337", "staging-brain");
|
||||
pub const BRAIN_TESTING: (&str, &str) = ("https://164.92.249.180:31337", "testnet-brain");
|
||||
pub(crate) const BRAIN_STAGING_URLS: [&str; 3] = [
|
||||
"https://184.107.169.199:49092",
|
||||
"https://149.22.95.1:47855",
|
||||
"https://149.36.48.99:48843",
|
||||
];
|
||||
pub(crate) const BRAIN_TESTING_URLS: [&str; 3] = [
|
||||
"https://184.107.169.199:45223",
|
||||
"https://149.22.95.1:44522",
|
||||
"https://149.36.48.99:48638",
|
||||
];
|
||||
pub const PACKAGE_ARCHIVE_POSTFIX: &str = "-enclave_package.tar.gz";
|
||||
pub const PACKAGE_ARCHIVE_DIR_PATH: &str = "/var/lib/detee/archives";
|
||||
pub const PACKAGE_DIR_PATH: &str = "/var/lib/detee/enclaves";
|
||||
|
||||
pub const APP_NAME_PREFIX: &str = "dtpm";
|
||||
|
||||
pub static BRAIN_STAGING: LazyLock<(&str, &str)> = LazyLock::new(|| {
|
||||
(
|
||||
BRAIN_STAGING_URLS[rand::thread_rng().gen_range(0..BRAIN_STAGING_URLS.len())],
|
||||
"staging-brain",
|
||||
)
|
||||
});
|
||||
|
||||
pub static BRAIN_TESTING: LazyLock<(&str, &str)> = LazyLock::new(|| {
|
||||
(
|
||||
BRAIN_TESTING_URLS[rand::thread_rng().gen_range(0..BRAIN_TESTING_URLS.len())],
|
||||
"testnet-brain",
|
||||
)
|
||||
});
|
||||
|
||||
// const DETEE_DIR_ENV_NAME: &str = "DETEE_DIR";
|
||||
|
||||
pub static IP_INFO: LazyLock<IPInfo> =
|
||||
|
@ -26,8 +26,8 @@ pub struct ConnectionData {
|
||||
|
||||
async fn client(network: &str) -> Result<BrainAppDaemonClient<Channel>> {
|
||||
let (brain_url, brain_san) = match network {
|
||||
"staging" => BRAIN_STAGING,
|
||||
"testnet" => BRAIN_TESTING,
|
||||
"staging" => *BRAIN_STAGING,
|
||||
"testnet" => *BRAIN_TESTING,
|
||||
_ => {
|
||||
return Err(anyhow::anyhow!(
|
||||
"The only networks currently supported are staging and testnet."
|
||||
|
Loading…
Reference in New Issue
Block a user