Skip to content
This repository has been archived by the owner on Jun 11, 2022. It is now read-only.

Commit

Permalink
add placeholders for the generic ntt implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
qnikst committed Feb 11, 2019
1 parent cfb2271 commit ad3c9de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions exe-common/src/config.rs
Expand Up @@ -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)
}
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion exe-common/src/network/ntt.rs
@@ -1,4 +1,5 @@
use futures::Future;
use futures::future::Executor;
use tokio_core::reactor::Core;

use network::api::{Api, BlockRef};
Expand Down Expand Up @@ -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!(),
Expand Down

0 comments on commit ad3c9de

Please sign in to comment.