Crates.io | tdn_permission |
lib.rs | tdn_permission |
version | 0.2.0 |
source | src |
created_at | 2020-09-16 04:36:16.096668 |
updated_at | 2020-09-16 04:36:16.096668 |
description | Multiple permissioned / permissionless libraries for TDN. |
homepage | |
repository | https://github.com/cypherlink/TDN-Permission |
max_upload_size | |
id | 289318 |
size | 72,662 |
Multiple permissioned / permissionless libraries for TDN.
use tdn::prelude::start;
use tdn_permission::PermissionlessGroup;
use tdn_types::message::{GroupReceiveMessage, ReceiveMessage};
fn main() {
smol::block_on(async {
let mut group = PermissionlessGroup::default();
let (_peer_addr, send, recv) = start().await.unwrap();
while let Ok(message) = recv.recv().await {
match message {
ReceiveMessage::Group(GroupReceiveMessage::PeerJoin(peer, addr, data)) => {
group.join(peer, addr, data, send.clone()).await;
}
ReceiveMessage::Group(GroupReceiveMessage::PeerJoinResult(peer, is_ok, result)) => {
group.join_result(peer, is_ok, result);
}
ReceiveMessage::Group(GroupReceiveMessage::PeerLeave(peer)) => {
group.leave(&peer);
}
_ => {
println!("recv: {:?}", message);
}
}
}
});
}
Test Public: cargo run --example permissionless
Test CA permissioned: cargo run --example ca_permissioned
Test Vote Permissioned: cargo run --example vote_permissioned
This project is licensed under either of
at your option.