Redirect to pubsub node and some bug fixes #8
| @ -1,3 +1,4 @@ | ||||
| use crate::constants::{STAGING_BRAIN_URLS, TESTNET_BRAIN_URLS}; | ||||
| use crate::{general, utils::block_on}; | ||||
| use ed25519_dalek::SigningKey; | ||||
| use log::{debug, info, warn}; | ||||
| @ -5,6 +6,7 @@ use openssl::bn::BigNum; | ||||
| use openssl::hash::{Hasher, MessageDigest}; | ||||
| use openssl::pkey::{PKey, Private}; | ||||
| use openssl::rsa::Rsa; | ||||
| use rand::Rng; | ||||
| use serde::{Deserialize, Serialize}; | ||||
| use std::{fs::File, io::Write, path::Path}; | ||||
| 
 | ||||
| @ -309,15 +311,19 @@ impl Config { | ||||
| 
 | ||||
|     pub fn get_brain_info() -> (String, String) { | ||||
|         match Self::init_config().network.as_str() { | ||||
|             "localhost" => ("https://localhost:31337".to_string(), "staging-brain".to_string()), | ||||
|             "staging" => { | ||||
|                 let url1 = "https://149.22.95.1:47855".to_string(); // staging brain 2
 | ||||
|                 let url2 = "https://149.36.48.99:48843".to_string(); // staging brain 3
 | ||||
| 
 | ||||
|                 let url = if rand::random::<bool>() { url1 } else { url2 }; | ||||
|                 let url = STAGING_BRAIN_URLS | ||||
|                     [rand::thread_rng().gen_range(0..STAGING_BRAIN_URLS.len())] | ||||
|                 .to_string(); | ||||
|                 (url, "staging-brain".to_string()) | ||||
|             } | ||||
|             "localhost" => ("https://localhost:31337".to_string(), "staging-brain".to_string()), | ||||
|             _ => ("https://173.234.17.2:39477".to_string(), "testnet-brain".to_string()), | ||||
|             _ => { | ||||
|                 let url = TESTNET_BRAIN_URLS | ||||
|                     [rand::thread_rng().gen_range(0..TESTNET_BRAIN_URLS.len())] | ||||
|                 .to_string(); | ||||
|                 (url, "testnet-brain".to_string()) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -1,2 +1,13 @@ | ||||
| pub const HRATLS_APP_PORT: u32 = 34500; | ||||
| pub const MAX_REDIRECTS: u16 = 3; | ||||
| pub const STAGING_BRAIN_URLS: [&str; 3] = [ | ||||
|     "https://184.107.169.199:49092", // staging brain 1
 | ||||
|     "https://149.22.95.1:47855",     // staging brain 2
 | ||||
|     "https://149.36.48.99:48843",    // staging brain 3
 | ||||
| ]; | ||||
| 
 | ||||
| pub const TESTNET_BRAIN_URLS: [&str; 3] = [ | ||||
|     "https://184.107.169.199:45223", // testnet brain 1
 | ||||
|     "https://149.22.95.1:44522",     // testnet brain 2
 | ||||
|     "https://149.36.48.99:48638",    // testnet brain 3
 | ||||
| ]; | ||||
|  | ||||
| @ -91,6 +91,7 @@ impl crate::HumanOutput for VmNodeListResp { | ||||
| 
 | ||||
| async fn client() -> Result<BrainVmCliClient<Channel>, Error> { | ||||
|     let default_brain_url = Config::get_brain_info().0; | ||||
|     info!("brain_url: {default_brain_url}"); | ||||
|     Ok(BrainVmCliClient::new(Config::connect_brain_channel(default_brain_url).await?)) | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user