use sodiumoxide;
use crust;
use std::sync::mpsc;
use sodiumoxide::crypto;
use std::sync::mpsc::{Receiver};
use super::*;
use types::DhtId;
type ConnectionManager = crust::ConnectionManager<DhtId>;
type Event = crust::Event<DhtId>;
pub struct RoutingNode<'a> {
facade: &'a (Facade + 'a),
sign_public_key: crypto::sign::PublicKey,
sign_secret_key: crypto::sign::SecretKey,
encrypt_public_key: crypto::asymmetricbox::PublicKey,
encrypt_secret_key: crypto::asymmetricbox::SecretKey,
event_input: Receiver<Event>,
connections: ConnectionManager,
}
impl<'a> RoutingNode<'a> {
pub fn new(id: types::DhtId, my_facade: &'a Facade) -> RoutingNode<'a> {
sodiumoxide::init(); let key_pair = crypto::sign::gen_keypair();
let encrypt_key_pair = crypto::asymmetricbox::gen_keypair();
let (event_output, event_input) = mpsc::channel();
RoutingNode { facade: my_facade,
sign_public_key: key_pair.0,
sign_secret_key: key_pair.1,
encrypt_public_key: encrypt_key_pair.0,
encrypt_secret_key: encrypt_key_pair.1,
event_input: event_input,
connections: crust::ConnectionManager::new(id, event_output)
}
}
pub fn get(&self, type_id: u64, name: types::DhtId) { unimplemented!()}
pub fn put(&self, name: types::DhtId, content: Vec<u8>) { unimplemented!() }
pub fn post(&self, name: types::DhtId, content: Vec<u8>) { unimplemented!() }
pub fn start() { }
fn add_bootstrap(&self) {}
fn get_facade(&'a mut self) -> &'a Facade {
self.facade
}
}
#[cfg(test)]
mod test {
}