Merge pull request #569 from ethcore/rpc_serde_generator
limit serde codegen only to rpc types submodule
This commit is contained in:
commit
f9533c5d16
@ -9,8 +9,8 @@ mod inner {
|
|||||||
pub fn main() {
|
pub fn main() {
|
||||||
let out_dir = env::var_os("OUT_DIR").unwrap();
|
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||||
|
|
||||||
let src = Path::new("src/lib.rs.in");
|
let src = Path::new("src/v1/types/mod.rs.in");
|
||||||
let dst = Path::new(&out_dir).join("lib.rs");
|
let dst = Path::new(&out_dir).join("mod.rs");
|
||||||
|
|
||||||
let mut registry = syntex::Registry::new();
|
let mut registry = syntex::Registry::new();
|
||||||
|
|
||||||
|
@ -28,8 +28,33 @@ extern crate ethcore_util as util;
|
|||||||
extern crate ethcore;
|
extern crate ethcore;
|
||||||
extern crate ethsync;
|
extern crate ethsync;
|
||||||
|
|
||||||
#[cfg(feature = "serde_macros")]
|
use self::jsonrpc_core::{IoHandler, IoDelegate};
|
||||||
include!("lib.rs.in");
|
|
||||||
|
|
||||||
#[cfg(not(feature = "serde_macros"))]
|
pub mod v1;
|
||||||
include!(concat!(env!("OUT_DIR"), "/lib.rs"));
|
|
||||||
|
/// Http server.
|
||||||
|
pub struct HttpServer {
|
||||||
|
handler: IoHandler,
|
||||||
|
threads: usize
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HttpServer {
|
||||||
|
/// Construct new http server object with given number of threads.
|
||||||
|
pub fn new(threads: usize) -> HttpServer {
|
||||||
|
HttpServer {
|
||||||
|
handler: IoHandler::new(),
|
||||||
|
threads: threads
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Add io delegate.
|
||||||
|
pub fn add_delegate<D>(&mut self, delegate: IoDelegate<D>) where D: Send + Sync + 'static {
|
||||||
|
self.handler.add_delegate(delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Start server asynchronously in new thread
|
||||||
|
pub fn start_async(self, addr: &str, cors_domain: &str) {
|
||||||
|
let server = jsonrpc_http_server::Server::new(self.handler, self.threads);
|
||||||
|
server.start_async(addr, jsonrpc_http_server::AccessControlAllowOrigin::Value(cors_domain.to_owned()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
use self::jsonrpc_core::{IoHandler, IoDelegate};
|
|
||||||
|
|
||||||
pub mod v1;
|
|
||||||
|
|
||||||
/// Http server.
|
|
||||||
pub struct HttpServer {
|
|
||||||
handler: IoHandler,
|
|
||||||
threads: usize
|
|
||||||
}
|
|
||||||
|
|
||||||
impl HttpServer {
|
|
||||||
/// Construct new http server object with given number of threads.
|
|
||||||
pub fn new(threads: usize) -> HttpServer {
|
|
||||||
HttpServer {
|
|
||||||
handler: IoHandler::new(),
|
|
||||||
threads: threads
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add io delegate.
|
|
||||||
pub fn add_delegate<D>(&mut self, delegate: IoDelegate<D>) where D: Send + Sync + 'static {
|
|
||||||
self.handler.add_delegate(delegate);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Start server asynchronously in new thread
|
|
||||||
pub fn start_async(self, addr: &str, cors_domain: &str) {
|
|
||||||
let server = jsonrpc_http_server::Server::new(self.handler, self.threads);
|
|
||||||
server.start_async(addr, jsonrpc_http_server::AccessControlAllowOrigin::Value(cors_domain.to_owned()))
|
|
||||||
}
|
|
||||||
}
|
|
@ -30,9 +30,7 @@ impl Web3Client {
|
|||||||
impl Web3 for Web3Client {
|
impl Web3 for Web3Client {
|
||||||
fn client_version(&self, params: Params) -> Result<Value, Error> {
|
fn client_version(&self, params: Params) -> Result<Value, Error> {
|
||||||
match params {
|
match params {
|
||||||
Params::None => {
|
Params::None => Ok(Value::String(version().to_owned().replace("Parity/", "Parity//"))),
|
||||||
Ok(Value::String(version().to_owned().replace("Parity/", "Parity//"))),
|
|
||||||
}
|
|
||||||
_ => Err(Error::invalid_params())
|
_ => Err(Error::invalid_params())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,22 +14,8 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
mod block;
|
#[cfg(feature = "serde_macros")]
|
||||||
mod block_number;
|
include!("mod.rs.in");
|
||||||
mod bytes;
|
|
||||||
mod filter;
|
|
||||||
mod index;
|
|
||||||
mod log;
|
|
||||||
mod optionals;
|
|
||||||
mod sync;
|
|
||||||
mod transaction;
|
|
||||||
|
|
||||||
pub use self::block::{Block, BlockTransactions};
|
#[cfg(not(feature = "serde_macros"))]
|
||||||
pub use self::block_number::BlockNumber;
|
include!(concat!(env!("OUT_DIR"), "/mod.rs"));
|
||||||
pub use self::bytes::Bytes;
|
|
||||||
pub use self::filter::Filter;
|
|
||||||
pub use self::index::Index;
|
|
||||||
pub use self::log::Log;
|
|
||||||
pub use self::optionals::OptionalValue;
|
|
||||||
pub use self::sync::{SyncStatus, SyncInfo};
|
|
||||||
pub use self::transaction::Transaction;
|
|
||||||
|
35
rpc/src/v1/types/mod.rs.in
Normal file
35
rpc/src/v1/types/mod.rs.in
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Parity is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
mod block;
|
||||||
|
mod block_number;
|
||||||
|
mod bytes;
|
||||||
|
mod filter;
|
||||||
|
mod index;
|
||||||
|
mod log;
|
||||||
|
mod optionals;
|
||||||
|
mod sync;
|
||||||
|
mod transaction;
|
||||||
|
|
||||||
|
pub use self::block::{Block, BlockTransactions};
|
||||||
|
pub use self::block_number::BlockNumber;
|
||||||
|
pub use self::bytes::Bytes;
|
||||||
|
pub use self::filter::Filter;
|
||||||
|
pub use self::index::Index;
|
||||||
|
pub use self::log::Log;
|
||||||
|
pub use self::optionals::OptionalValue;
|
||||||
|
pub use self::sync::{SyncStatus, SyncInfo};
|
||||||
|
pub use self::transaction::Transaction;
|
Loading…
Reference in New Issue
Block a user