repo: updated everything to merged stuff

This commit is contained in:
aggstam
2023-06-29 16:13:43 +03:00
parent b4d28da805
commit 1ea8adfb28
16 changed files with 41 additions and 70 deletions

View File

@@ -19,19 +19,15 @@
// ANCHOR: msg
use async_std::sync::{Arc, Mutex};
use darkfi::net;
use darkfi::{impl_p2p_message, net::Message};
use darkfi_serial::{SerialDecodable, SerialEncodable};
pub type DchatMsgsBuffer = Arc<Mutex<Vec<DchatMsg>>>;
impl net::Message for DchatMsg {
fn name() -> &'static str {
"DchatMsg"
}
}
#[derive(Debug, Clone, SerialEncodable, SerialDecodable)]
pub struct DchatMsg {
pub msg: String,
}
impl_p2p_message!(DchatMsg, "DchatMsg");
// ANCHOR_END: msg

View File

@@ -113,7 +113,7 @@ impl Dchat {
debug!(target: "dchat", "Dchat::register_protocol() [START]");
let registry = self.p2p.protocol_registry();
registry
.register(!net::SESSION_SEED, move |channel, _p2p| {
.register(!net::session::SESSION_SEED, move |channel, _p2p| {
let msgs2 = msgs.clone();
async move { ProtocolDchat::init(channel, msgs2).await }
})
@@ -145,7 +145,7 @@ impl Dchat {
// ANCHOR: send
async fn send(&self, msg: String) -> Result<()> {
let dchatmsg = DchatMsg { msg };
self.p2p.broadcast(dchatmsg).await?;
self.p2p.broadcast(&dchatmsg).await;
Ok(())
}
// ANCHOR_END: send
@@ -179,8 +179,8 @@ fn alice() -> Result<AppSettings> {
let ext_addr = Url::parse("tcp://127.0.0.1:51554").unwrap();
let net = Settings {
inbound: vec![inbound],
external_addr: vec![ext_addr],
inbound_addrs: vec![inbound],
external_addrs: vec![ext_addr],
seeds: vec![seed],
localnet: true,
..Default::default()
@@ -205,7 +205,7 @@ fn bob() -> Result<AppSettings> {
let seed = Url::parse("tcp://127.0.0.1:50515").unwrap();
let net = Settings {
inbound: vec![],
inbound_addrs: vec![],
outbound_connections: 5,
seeds: vec![seed],
localnet: true,

View File

@@ -36,7 +36,7 @@ pub struct ProtocolDchat {
impl ProtocolDchat {
pub async fn init(channel: net::ChannelPtr, msgs: DchatMsgsBuffer) -> net::ProtocolBasePtr {
debug!(target: "dchat", "ProtocolDchat::init() [START]");
let message_subsytem = channel.get_message_subsystem();
let message_subsytem = channel.message_subsystem();
message_subsytem.add_dispatch::<DchatMsg>().await;
let msg_sub =

View File

@@ -55,7 +55,7 @@ pub struct DarkCli {
pub connect: Option<Vec<String>>,
/// connections slots
#[clap(long)]
pub connect_slots: Option<u32>,
pub connect_slots: Option<usize>,
/// RPC port
#[clap(long)]
pub rpc_port: Option<String>,
@@ -93,9 +93,9 @@ impl ProgramOptions {
Ok(ProgramOptions {
network_settings: net::Settings {
inbound: accept_addr.clone(),
inbound_addrs: accept_addr.clone(),
outbound_connections: connection_slots,
external_addr: accept_addr,
external_addrs: accept_addr,
peers: manual_connects,
seeds: seed_addrs,
..Default::default()
@@ -108,7 +108,7 @@ fn main() -> Result<()> {
let options = ProgramOptions::load()?;
let lvl = get_log_level(1);
let conf = get_log_config();
let conf = get_log_config(1);
TermLogger::init(lvl, conf, TerminalMode::Mixed, ColorChoice::Auto)?;