mirror of
https://github.com/serai-dex/serai.git
synced 2025-04-22 22:18:15 +00:00
Define an array of all NetworkIds in serai_primitives
This commit is contained in:
parent
b7746aa71d
commit
6a4c57e86f
6 changed files with 20 additions and 14 deletions
coordinator/src
message-queue/src
substrate
client/tests
node/src
primitives/src
validator-sets/pallet/src
|
@ -987,7 +987,10 @@ pub async fn handle_processors<D: Db, Pro: Processors, P: P2p>(
|
|||
mut new_tributary: broadcast::Receiver<ActiveTributary<D, P>>,
|
||||
) {
|
||||
let mut channels = HashMap::new();
|
||||
for network in [NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero] {
|
||||
for network in serai_client::primitives::NETWORKS {
|
||||
if network == NetworkId::Serai {
|
||||
continue;
|
||||
}
|
||||
let (send, recv) = mpsc::unbounded_channel();
|
||||
tokio::spawn(handle_processor_messages(
|
||||
db.clone(),
|
||||
|
|
|
@ -183,14 +183,14 @@ async fn main() {
|
|||
Some(<Ristretto as Ciphersuite>::G::from_bytes(&repr).unwrap())
|
||||
};
|
||||
|
||||
const ALL_EXT_NETWORKS: [NetworkId; 3] =
|
||||
[NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero];
|
||||
|
||||
let register_service = |service, key| {
|
||||
(*KEYS).write().unwrap().insert(service, key);
|
||||
let mut queues = (*QUEUES).write().unwrap();
|
||||
if service == Service::Coordinator {
|
||||
for network in ALL_EXT_NETWORKS {
|
||||
for network in serai_primitives::NETWORKS {
|
||||
if network == NetworkId::Serai {
|
||||
continue;
|
||||
}
|
||||
queues.insert(
|
||||
(service, Service::Processor(network)),
|
||||
RwLock::new(Queue(db.clone(), service, Service::Processor(network))),
|
||||
|
@ -205,7 +205,10 @@ async fn main() {
|
|||
};
|
||||
|
||||
// Make queues for each NetworkId, other than Serai
|
||||
for network in ALL_EXT_NETWORKS {
|
||||
for network in serai_primitives::NETWORKS {
|
||||
if network == NetworkId::Serai {
|
||||
continue;
|
||||
}
|
||||
// Use a match so we error if the list of NetworkIds changes
|
||||
let Some(key) = read_key(match network {
|
||||
NetworkId::Serai => unreachable!(),
|
||||
|
|
|
@ -3,7 +3,7 @@ use rand_core::{RngCore, OsRng};
|
|||
use sp_core::{sr25519::Public, Pair};
|
||||
|
||||
use serai_client::{
|
||||
primitives::{NetworkId, insecure_pair_from_name},
|
||||
primitives::{NETWORKS, NetworkId, insecure_pair_from_name},
|
||||
validator_sets::{
|
||||
primitives::{Session, ValidatorSet, musig_key},
|
||||
ValidatorSetsEvent,
|
||||
|
@ -38,7 +38,7 @@ serai_test!(
|
|||
.get_new_set_events(serai.get_block_by_number(0).await.unwrap().unwrap().hash())
|
||||
.await
|
||||
.unwrap(),
|
||||
[NetworkId::Serai, NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero]
|
||||
NETWORKS
|
||||
.iter()
|
||||
.copied()
|
||||
.map(|network| ValidatorSetsEvent::NewSet {
|
||||
|
|
|
@ -56,8 +56,7 @@ fn testnet_genesis(
|
|||
|
||||
validator_sets: ValidatorSetsConfig {
|
||||
stake: Amount(1_000_000 * 10_u64.pow(8)),
|
||||
// TODO: Array of these in primitives
|
||||
networks: vec![NetworkId::Serai, NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero],
|
||||
networks: serai_runtime::primitives::NETWORKS.to_vec(),
|
||||
participants: validators.iter().map(|name| account_from_name(name)).collect(),
|
||||
},
|
||||
session: SessionConfig { keys: validators.iter().map(|name| session_key(*name)).collect() },
|
||||
|
|
|
@ -31,6 +31,9 @@ pub enum NetworkId {
|
|||
Monero,
|
||||
}
|
||||
|
||||
pub const NETWORKS: [NetworkId; 4] =
|
||||
[NetworkId::Serai, NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero];
|
||||
|
||||
/// The type used to identify coins.
|
||||
#[derive(
|
||||
Clone,
|
||||
|
|
|
@ -32,7 +32,7 @@ pub mod pallet {
|
|||
///
|
||||
/// Every participant at genesis will automatically be assumed to have this much stake.
|
||||
/// This stake cannot be withdrawn however as there's no actual stake behind it.
|
||||
// TODO: Localize stake to network?
|
||||
// TODO: Localize stake to network
|
||||
pub stake: Amount,
|
||||
/// Networks to spawn Serai with.
|
||||
pub networks: Vec<NetworkId>,
|
||||
|
@ -572,9 +572,7 @@ pub mod pallet {
|
|||
}
|
||||
|
||||
pub fn new_session() {
|
||||
// TODO: Define an array of all networks in primitives
|
||||
let networks = [NetworkId::Serai, NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero];
|
||||
for network in networks {
|
||||
for network in serai_primitives::NETWORKS {
|
||||
let current_session = Self::session(network);
|
||||
// Only spawn a NewSet if the current set was actually established with a completed
|
||||
// handover protocol
|
||||
|
|
Loading…
Reference in a new issue