Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/channel/channel.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use tokio::runtime::Runtime;

use crate::{
identification::{allow_list::AllowList, identifier::Identifier},
rpc::{
Expand Down Expand Up @@ -40,6 +42,29 @@ impl DualChannel {
})
}

pub fn new_with_runtime(
config: &BrokerConfig,
my_cert: Cert,
my_id: Option<u8>,
allow_list: Arc<Mutex<AllowList>>,
rt: Arc<Mutex<Runtime>>,
) -> Result<Self, crate::rpc::errors::BrokerError> {
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,
Expand Down
Loading