Merge pull request #1313 from ethcore/net

Network start/stop
This commit is contained in:
Arkadiy Paronyan
2016-06-18 11:04:24 +02:00
committed by GitHub
19 changed files with 298 additions and 109 deletions

View File

@@ -47,4 +47,14 @@ impl<S> Net for NetClient<S> where S: SyncProvider + 'static {
// right now (11 march 2016), we are always listening for incoming connections
Ok(Value::Bool(true))
}
fn start_network(&self, _: Params) -> Result<Value, Error> {
take_weak!(self.sync).start_network();
Ok(Value::Bool(true))
}
fn stop_network(&self, _: Params) -> Result<Value, Error> {
take_weak!(self.sync).stop_network();
Ok(Value::Bool(true))
}
}

View File

@@ -59,5 +59,11 @@ impl SyncProvider for TestSyncProvider {
fn status(&self) -> SyncStatus {
self.status.read().unwrap().clone()
}
fn start_network(&self) {
}
fn stop_network(&self) {
}
}

View File

@@ -30,6 +30,12 @@ pub trait Net: Sized + Send + Sync + 'static {
/// Otherwise false.
fn is_listening(&self, _: Params) -> Result<Value, Error>;
/// Start the network.
fn start_network(&self, _: Params) -> Result<Value, Error>;
/// Stop the network.
fn stop_network(&self, _: Params) -> Result<Value, Error>;
/// Should be used to convert object to io delegate.
fn to_delegate(self) -> IoDelegate<Self> {
let mut delegate = IoDelegate::new(Arc::new(self));