mod network_layer;
pub mod p2p_protocol;
pub mod real_engine;
mod space_layer;
use std::collections::{HashMap, HashSet, VecDeque};
use crate::{
dht::dht_trait::{Dht, DhtFactory},
gateway::P2pGateway,
transport::{transport_trait::Transport, ConnectionId},
transport_wss::TlsConfig,
};
use lib3h_crypto_api::{Buffer, CryptoSystem};
use lib3h_protocol::{protocol_client::Lib3hClientProtocol, Address};
use std::{cell::RefCell, rc::Rc};
use url::Url;
pub type ChainId = (Address, Address);
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct RealEngineConfig {
pub tls_config: TlsConfig,
pub socket_type: String,
pub bootstrap_nodes: Vec<String>,
pub work_dir: String,
pub log_level: char,
#[serde(with = "url_serde")]
pub bind_url: Url,
pub dht_custom_config: Vec<u8>,
}
#[allow(dead_code)]
pub struct TransportKeys<SecBuf: Buffer, Crypto: CryptoSystem> {
pub transport_id: String,
pub transport_public_key: Vec<u8>,
pub transport_secret_key: SecBuf,
pub phantom_crypto: std::marker::PhantomData<Crypto>,
}
pub struct RealEngine<T: Transport, D: Dht, SecBuf: Buffer, Crypto: CryptoSystem> {
name: String,
config: RealEngineConfig,
inbox: VecDeque<Lib3hClientProtocol>,
dht_factory: DhtFactory<D>,
#[allow(dead_code)]
network_transport: Rc<RefCell<T>>,
network_gateway: Rc<RefCell<P2pGateway<T, D>>>,
network_connections: HashSet<ConnectionId>,
space_gateway_map: HashMap<ChainId, P2pGateway<P2pGateway<T, D>, D>>,
#[allow(dead_code)]
transport_keys: TransportKeys<SecBuf, Crypto>,
}