Permalink
Browse files

add placeholders for the generic ntt implementation

  • Loading branch information...
qnikst committed Feb 11, 2019
1 parent cfb2271 commit ad3c9de9fc20bdc0d3e2351d41e9460c4ac655eb
Showing with 21 additions and 1 deletion.
  1. +19 −0 exe-common/src/config.rs
  2. +2 −1 exe-common/src/network/ntt.rs
@@ -57,6 +57,8 @@ pub mod net {
pub fn new(addr: String) -> Self {
if addr.starts_with(r"http://") || addr.starts_with(r"https://") {
Peer::http(addr)
} else if addr.starts_with(r"ntt://") {
Peer::ntt(addr)
} else {
Peer::native(addr)
}
@@ -70,6 +72,10 @@ pub mod net {
pub fn http(addr: String) -> Self {
Peer::Http(addr)
}
/// force constructing a http `Peer`.
pub fn ntt(addr: String) -> Self {
Peer::Ntt(addr)
}
/// return the content of the native peer if the given object is a native peer.
pub fn get_native(&self) -> Option<&str> {
match self {
@@ -84,6 +90,15 @@ pub mod net {
_ => None,
}
}
/// return the content of the ntt peer if the given object is a http peer.
pub fn get_ntt(&self) -> Option<&str> {
match self {
&Peer::Ntt(ref addr) => Some(addr.as_ref()),
_ => None,
}
}


/// get the address, indifferent to whether the `Peer` is a native or
/// a http `Peer`.
pub fn get_address(&self) -> &str {
@@ -101,6 +116,10 @@ pub mod net {
pub fn is_http(&self) -> bool {
self.get_http().is_some()
}
/// test if the `Peer` is a http `Peer`.
pub fn is_ntt(&self) -> bool {
self.get_ntt().is_some()
}
}
impl fmt::Display for Peer {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -1,4 +1,5 @@
use futures::Future;
use futures::future::Executor;
use tokio_core::reactor::Core;

use network::api::{Api, BlockRef};
@@ -26,7 +27,7 @@ impl NetworkCore {
match connecting.wait() {
Ok((connection, handle)) => {
let mut core = Core::new().unwrap();
core.run(connection);
core.execute(connection).unwrap();
Ok(NetworkCore { handle, core })
}
Err(_err) => unimplemented!(),

0 comments on commit ad3c9de

Please sign in to comment.