diff --git a/ipc/codegen/src/codegen.rs b/ipc/codegen/src/codegen.rs index 5385c72d7..47fd9a1ba 100644 --- a/ipc/codegen/src/codegen.rs +++ b/ipc/codegen/src/codegen.rs @@ -36,6 +36,8 @@ use syntax::ptr::P; pub struct Error; +const RESERVED_MESSAGE_IDS: u16 = 16; + pub fn expand_ipc_implementation( cx: &mut ExtCtxt, span: Span, diff --git a/ipc/rpc/Cargo.toml b/ipc/rpc/Cargo.toml index 99fcd3233..b5177db41 100644 --- a/ipc/rpc/Cargo.toml +++ b/ipc/rpc/Cargo.toml @@ -8,3 +8,4 @@ license = "GPL-3.0" [dependencies] ethcore-devtools = { path = "../../devtools" } +semver = "0.2.0" diff --git a/ipc/rpc/src/interface.rs b/ipc/rpc/src/interface.rs index 7ed8b60c4..060da36a9 100644 --- a/ipc/rpc/src/interface.rs +++ b/ipc/rpc/src/interface.rs @@ -19,8 +19,24 @@ use std::io::{Read, Write}; use std::marker::Sync; use std::sync::atomic::*; +use semver::Version; -pub trait IpcInterface { +pub struct Handshake { + protocol_version: Version, + api_version: Version, + reserved: [u8; 64], +} + +pub trait IpcConfig { + fn api_version() -> Version { + Version::parse("1.0.0").unwrap() + } + fn protocol_version() -> Version { + Version::parse("1.0.0").unwrap() + } +} + +pub trait IpcInterface where T: IpcConfig { /// reads the message from io, dispatches the call and returns serialized result fn dispatch(&self, r: &mut R) -> Vec where R: Read; diff --git a/ipc/rpc/src/lib.rs b/ipc/rpc/src/lib.rs index f8c68cdbd..a0d718871 100644 --- a/ipc/rpc/src/lib.rs +++ b/ipc/rpc/src/lib.rs @@ -17,6 +17,7 @@ //! IPC RPC interface extern crate ethcore_devtools as devtools; +extern crate semver; pub mod interface; -pub use interface::{IpcInterface, IpcSocket, invoke}; +pub use interface::{IpcInterface, IpcSocket, invoke, IpcConfig}; diff --git a/ipc/tests/Cargo.toml b/ipc/tests/Cargo.toml index 1d2bc35b4..d6d066b93 100644 --- a/ipc/tests/Cargo.toml +++ b/ipc/tests/Cargo.toml @@ -12,6 +12,7 @@ path = "run.rs" bincode = "*" serde = "0.7.0" ethcore-devtools = { path = "../../devtools" } +semver = "0.2.0" [build-dependencies] syntex = "0.30.0" diff --git a/ipc/tests/examples.rs b/ipc/tests/examples.rs index 52ac0cf22..32c8206ed 100644 --- a/ipc/tests/examples.rs +++ b/ipc/tests/examples.rs @@ -20,6 +20,7 @@ mod tests { use super::super::service::*; use ipc::*; use devtools::*; + use semver::Version; #[test] fn call_service() { @@ -57,4 +58,12 @@ mod tests { assert_eq!(vec![0, 1, 1, 0, 0, 0, 5, 0, 0, 0, 10], service_client.socket().borrow().write_buffer.clone()); assert_eq!(10, result); } + + #[test] + fn query_default_version() { + let ver = Service::protocol_version(); + assert_eq!(ver, Version::parse("1.0.0").unwrap()); + let ver = Service::api_version(); + assert_eq!(ver, Version::parse("1.0.0").unwrap()); + } } diff --git a/ipc/tests/run.rs b/ipc/tests/run.rs index 7aac809ed..e464d186f 100644 --- a/ipc/tests/run.rs +++ b/ipc/tests/run.rs @@ -18,6 +18,7 @@ extern crate bincode; extern crate ethcore_ipc as ipc; extern crate serde; extern crate ethcore_devtools as devtools; +extern crate semver; pub mod service; mod examples; diff --git a/ipc/tests/service.rs.in b/ipc/tests/service.rs.in index 2b529534a..14de716da 100644 --- a/ipc/tests/service.rs.in +++ b/ipc/tests/service.rs.in @@ -45,3 +45,5 @@ impl Service { } } } + +impl ::ipc::IpcConfig for Service {}