2 releases
0.0.1 | Jun 26, 2024 |
---|---|
0.0.0 | Jan 6, 2021 |
#9 in #bitmessage
Used in 4 crates
455KB
11K
SLoC
This crate is a Bitmessage node implementation as a library for Koibumi (sync version), an experimental Bitmessage client.
See koibumi-sync
for more about the application.
See Bitmessage for more about the protocol.
lib.rs
:
This crate is a Bitmessage node implementation as a library for Koibumi (sync version), an experimental Bitmessage client.
See koibumi-sync
for more about the application.
See Bitmessage for more about the protocol.
Examples
use std::{path::PathBuf, str::FromStr};
use koibumi_node_sync::{self as node, Command, Config, Event, Response};
let (command_sender, mut response_receiver, handle) = node::spawn();
let config = Config::builder()
.server(Some("127.0.0.1:8444".parse().unwrap()))
.socks(Some("127.0.0.1:9050".parse().unwrap()))
.connect_to_onion(true)
.connect_to_ip(true)
.seeds(vec!["quzwelsuziwqgpt2.onion:8444".parse().unwrap()])
.build();
let mut sender = command_sender;
let response = {
let db_path = PathBuf::from_str("sqlite::memory:").unwrap();
if let Err(err) = sender.send(Command::Start(config.into(), db_path, Vec::new())) {
eprintln!("{}", err);
return
}
response_receiver.recv()
};
let Response::Started(mut receiver) = response.unwrap();
while let Ok(event) = receiver.recv() {
match event {
Event::ConnectionCounts { .. } => (),
Event::AddrCount(_count) => (),
Event::Established { addr, user_agent, rating } => {
println!("established: {} {} rating:{}", addr, user_agent, rating);
}
Event::Disconnected { addr } => {
println!("disconnected: {}", addr);
}
Event::Objects { .. } => (),
Event::Stopped => {
break;
}
Event::Broadcast {
user_id,
address,
object,
} => {
println!("broadcast received from {}", address);
}
Event::Msg {
user_id,
address,
object,
} => {
println!("received msg for {}", address);
}
}
}
if let Err(err) = handle.join() {
eprintln!("{:?}", err);
return
}
Dependencies
~32MB
~550K SLoC