diff --git a/src/channel/channel.rs b/src/channel/channel.rs index 4980bc5..10ac994 100644 --- a/src/channel/channel.rs +++ b/src/channel/channel.rs @@ -1,3 +1,5 @@ +use tokio::runtime::Runtime; + use crate::{ identification::{allow_list::AllowList, identifier::Identifier}, rpc::{ @@ -40,6 +42,29 @@ impl DualChannel { }) } + pub fn new_with_runtime( + config: &BrokerConfig, + my_cert: Cert, + my_id: Option, + allow_list: Arc>, + rt: Arc>, + ) -> Result { + let client = SyncClient::new_with_runtime(config, my_cert.clone(), allow_list, rt)?; + let my_id = Identifier { + pubkey_hash: my_cert.get_pubk_hash()?, + id: my_id.unwrap_or(0), // Default to 0 if not provided + }; + let dest_id = Identifier { + pubkey_hash: config.get_pubk_hash(), + id: config.get_id(), + }; + Ok(Self { + client, + my_id, + dest_id, + }) + } + // Do not use in production, this is for testing purposes only pub fn new_simple( config: &BrokerConfig,