Trusted Distributed Network. (Also a micro-framework for building decentralized applications)
TDN: Let data transfer safely, make the network stable, secure, and highly available.
As the network interconnection, TDN includes peer-to-peer, centralized gateway, proxy & relay service, LAN, RPC, Near, etc.
As the framework of decentralized applications, TDN uses the Layer and Group models. We built this framework because we feel that the blockchain is very limited. If you want a more open and free distributed application development technology, and Pluggable, lightweight application framework, TDN can satisfy you.
Example
use std::sync::Arc;
use tdn::prelude::*;
use tdn::types::rpc::{json, RpcError, RpcHandler, RpcParam};
struct State(u32);
#[tokio::main] async fn main() { let (peeraddr, send, mut outrecv) = start().await.unwrap(); println!("Example: peer id: {:?}", peer_addr);
let mut rpc_handler = RpcHandler::new(State(1)); rpchandler.addmethod("sayhello", |params: Vec<RpcParam>, state: Arc<State>| async move { assert_eq!(1, state.0); Ok(HandleResult::rpc(json!("hello"))) });
while let Some(message) = out_recv.recv().await { match message { ReceiveMessage::Own(msg) => match msg { RecvType::Connect(peer, _data) => { println!("receive own peer {} join", peer.id.short_show()); } RecvType::Leave(peer) => { println!("receive own peer {} leave", peer.id.short_show()); } RecvType::Event(peerid, data) => { println!("receive own event from {}", peerid.shortshow()); } _ => { println!("nerver here!") } }, ReceiveMessage::Group(msg) => match msg { RecvType::Connect(peer, _data) => { println!("receive group peer {} join", peer.id.short_show()); } RecvType::Result(..) => { // } RecvType::Leave(peer) => { println!("receive group peer {} leave", peer.id.short_show()); } RecvType::Event(peerid, data) => { println!("receive group event from {}", peerid.shortshow()); } _ => {} }, ReceiveMessage::Layer(fgid, _tgid, msg) => match msg { RecvType::Connect(peer, _data) => { println!("Layer Join: {}, Addr: {}.", fgid, peer.id.short_show()); } RecvType::Result(..) => { // } _ => {} }, ReceiveMessage::Rpc(uid, params, is_ws) => { if let Ok(HandleResult { mut rpcs, owns: _, groups: _, layers: _, networks: _, }) = rpc_handler.handle(params).await { loop { if rpcs.len() != 0 { let msg = rpcs.remove(0); send.send(SendMessage::Rpc(uid, msg, is_ws)) .await .expect("TDN channel closed"); } else { break; } } } } ReceiveMessage::NetworkLost => { println!("No network connections"); } } } }
- install
lastestRust andcd ./tdn cargo run --example simpleCongratulation, you are running a trusted distributed network :)
Features
- Support different data structures
- Support different consensus algorithms
- Support different permission mechanisms
- Support different account systems
- Applications can communicate with others
- Trust can be passed on and accumulated
4-type Applications
TDN can build 4-type network for applications. Usefeature to control. (Tip: one group, is one chain, is one application)
- single. Support only one group, and no layers. Like
Bitcoin. - std (default). Support only one group, and multiple layers (cross-chain, Interactive with other groups).
- multiple. Support many groups (in one runtime, support many applications), and no layers. Like
Ethereum. - full. Support many groups, and multiple layers.
Architecture

Pluggable library
- tdn-did decentralized identity.
- tdn-storage Storage library, include Local file, Local db, Distributed db, Decentralized db.
- tdn-permission Group permission library, include permissioned & permissionless group algorithm.
Core QA
- What is Layers & Groups?
Group is application, one application is one group, Layer is communication between apps. In the Group, users can define everything. The Layer is divided into upper and lower, upper is this application depends on others, lower is others depends on this. If app is an independent application that does not interact with other applications, then you can completely ignore Layer.
- Different consensus?
- Different permission?
Layer supports applications in different permission environments, allowing data interaction.
- Different block & transaction data structure?
- Different account system?
License
This project is licensed under either of
* Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) * MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
