port network, sync, rpc

This commit is contained in:
Robert Habermeier 2016-09-01 14:49:12 +02:00
parent 5dd56aa070
commit d763664d16
21 changed files with 54 additions and 40 deletions

3
Cargo.lock generated
View File

@ -416,6 +416,7 @@ dependencies = [
"mio 0.5.1 (git+https://github.com/ethcore/mio?branch=v0.5.x)",
"parking_lot 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.1.0",
"rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"slab 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -442,6 +443,7 @@ dependencies = [
"jsonrpc-core 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-http-server 6.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.1.0",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_codegen 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)",
@ -588,6 +590,7 @@ dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.1.0",
"semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
]

View File

@ -23,6 +23,7 @@ ethash = { path = "../ethash" }
ethsync = { path = "../sync" }
ethjson = { path = "../json" }
ethcore-devtools = { path = "../devtools" }
rlp = { path = "../util/rlp" }
rustc-serialize = "0.3"
transient-hashmap = "0.1"
serde_macros = { version = "0.7.0", optional = true }

View File

@ -19,15 +19,12 @@
#![cfg_attr(feature="nightly", feature(custom_derive, custom_attribute, plugin))]
#![cfg_attr(feature="nightly", plugin(serde_macros, clippy))]
#[macro_use]
extern crate log;
extern crate rustc_serialize;
extern crate serde;
extern crate serde_json;
extern crate jsonrpc_core;
extern crate jsonrpc_http_server;
#[macro_use]
extern crate ethcore_util as util;
extern crate ethcore_io as io;
extern crate ethcore;
extern crate ethkey;
@ -37,6 +34,12 @@ extern crate transient_hashmap;
extern crate json_ipc_server as ipc;
extern crate ethcore_ipc;
extern crate time;
extern crate rlp;
#[macro_use]
extern crate log;
#[macro_use]
extern crate ethcore_util as util;
#[cfg(test)]
extern crate ethjson;

View File

@ -15,7 +15,6 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use util::{Address, H256, U256, Uint};
use util::rlp::encode;
use util::bytes::ToPretty;
use ethcore::miner::MinerService;
use ethcore::client::MiningBlockChainClient;
@ -70,7 +69,7 @@ pub fn unlock_sign_and_dispatch<C, M>(client: &C, miner: &M, request: Transactio
t.with_signature(signature)
};
trace!(target: "miner", "send_transaction: dispatching tx: {}", encode(&signed_transaction).to_vec().pretty());
trace!(target: "miner", "send_transaction: dispatching tx: {}", ::rlp::encode(&signed_transaction).to_vec().pretty());
dispatch_transaction(&*client, &*miner, signed_transaction)
}
@ -84,7 +83,7 @@ pub fn sign_and_dispatch<C, M>(client: &C, miner: &M, request: TransactionReques
t.with_signature(signature)
};
trace!(target: "miner", "send_transaction: dispatching tx: {}", encode(&signed_transaction).to_vec().pretty());
trace!(target: "miner", "send_transaction: dispatching tx: {}", ::rlp::encode(&signed_transaction).to_vec().pretty());
dispatch_transaction(&*client, &*miner, signed_transaction)
}

View File

@ -29,8 +29,8 @@ use ethcore::miner::{MinerService, ExternalMinerService};
use jsonrpc_core::*;
use util::{H256, Address, FixedHash, U256, H64, Uint};
use util::sha3::*;
use util::rlp::{encode, decode, UntrustedRlp, View};
use util::{FromHex, Mutex};
use rlp::{self, UntrustedRlp, View};
use ethcore::account_provider::AccountProvider;
use ethcore::client::{MiningBlockChainClient, BlockID, TransactionID, UncleID};
use ethcore::header::Header as BlockHeader;
@ -123,7 +123,7 @@ impl<C, S: ?Sized, M, EM> EthClient<C, S, M, EM> where
timestamp: view.timestamp().into(),
difficulty: view.difficulty().into(),
total_difficulty: total_difficulty.into(),
seal_fields: view.seal().into_iter().map(|f| decode(&f)).map(Bytes::new).collect(),
seal_fields: view.seal().into_iter().map(|f| rlp::decode(&f)).map(Bytes::new).collect(),
uncles: block_view.uncle_hashes().into_iter().map(Into::into).collect(),
transactions: match include_txs {
true => BlockTransactions::Full(block_view.localized_transactions().into_iter().map(Into::into).collect()),
@ -147,7 +147,7 @@ impl<C, S: ?Sized, M, EM> EthClient<C, S, M, EM> where
fn uncle(&self, id: UncleID) -> Result<Value, Error> {
let client = take_weak!(self.client);
let uncle: BlockHeader = match client.uncle(id) {
Some(rlp) => decode(&rlp),
Some(rlp) => rlp::decode(&rlp),
None => { return Ok(Value::Null); }
};
let parent_difficulty = match client.block_total_difficulty(BlockID::Hash(uncle.parent_hash().clone())) {
@ -173,7 +173,7 @@ impl<C, S: ?Sized, M, EM> EthClient<C, S, M, EM> where
total_difficulty: (uncle.difficulty().clone() + parent_difficulty).into(),
receipts_root: uncle.receipts_root().clone().into(),
extra_data: uncle.extra_data().clone().into(),
seal_fields: uncle.seal().clone().into_iter().map(|f| decode(&f)).map(Bytes::new).collect(),
seal_fields: uncle.seal().clone().into_iter().map(|f| rlp::decode(&f)).map(Bytes::new).collect(),
uncles: vec![],
transactions: BlockTransactions::Hashes(vec![]),
};
@ -566,7 +566,7 @@ impl<C, S: ?Sized, M, EM> Eth for EthClient<C, S, M, EM> where
trace!(target: "miner", "submit_work: Decoded: nonce={}, pow_hash={}, mix_hash={}", nonce, pow_hash, mix_hash);
let miner = take_weak!(self.miner);
let client = take_weak!(self.client);
let seal = vec![encode(&mix_hash).to_vec(), encode(&nonce).to_vec()];
let seal = vec![rlp::encode(&mix_hash).to_vec(), rlp::encode(&nonce).to_vec()];
let r = miner.submit_seal(&*client, pow_hash, seal);
to_value(&r.is_ok())
})

View File

@ -18,7 +18,7 @@
use std::sync::{Weak, Arc};
use jsonrpc_core::*;
use util::rlp::{UntrustedRlp, View};
use rlp::{UntrustedRlp, View};
use ethcore::client::{BlockChainClient, CallAnalytics, TransactionID, TraceId};
use ethcore::miner::MinerService;
use ethcore::transaction::{Transaction as EthTransaction, SignedTransaction, Action};

View File

@ -364,7 +364,7 @@ fn rpc_eth_pending_transaction_by_hash() {
let tester = EthTester::default();
{
let tx: SignedTransaction = decode(&FromHex::from_hex("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap());
let tx: SignedTransaction = ::rlp::decode(&FromHex::from_hex("f85f800182520894095e7baea6a6c7c4c2dfeb977efac326af552d870a801ba048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353a0efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804").unwrap());
tester.miner.pending_transactions.lock().insert(H256::zero(), tx);
}
@ -705,7 +705,7 @@ fn rpc_eth_send_raw_transaction() {
let signature = tester.accounts_provider.sign(address, t.hash()).unwrap();
let t = t.with_signature(signature);
let rlp = ::util::rlp::encode(&t).to_vec().to_hex();
let rlp = ::rlp::encode(&t).to_vec().to_hex();
let req = r#"{
"jsonrpc": "2.0",

View File

@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use util::rlp::encode;
use ethcore::contract_address;
use ethcore::transaction::{LocalizedTransaction, Action, SignedTransaction};
use v1::types::{Bytes, H160, H256, U256};
@ -75,7 +74,7 @@ impl From<LocalizedTransaction> for Transaction {
Action::Create => Some(contract_address(&t.sender().unwrap(), &t.nonce).into()),
Action::Call(_) => None,
},
raw: encode(&t.signed).to_vec().into(),
raw: ::rlp::encode(&t.signed).to_vec().into(),
}
}
}
@ -101,7 +100,7 @@ impl From<SignedTransaction> for Transaction {
Action::Create => Some(contract_address(&t.sender().unwrap(), &t.nonce).into()),
Action::Call(_) => None,
},
raw: encode(&t).to_vec().into(),
raw: ::rlp::encode(&t).to_vec().into(),
}
}
}

View File

@ -16,6 +16,7 @@ ethcore-util = { path = "../util" }
ethcore-network = { path = "../util/network" }
ethcore-io = { path = "../util/io" }
ethcore = { path = "../ethcore" }
rlp = { path = "../util/rlp" }
clippy = { version = "0.0.85", optional = true}
log = "0.3"
env_logger = "0.3"

View File

@ -15,6 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use util::*;
use rlp::*;
use network::NetworkError;
use ethcore::header::{ Header as BlockHeader};
@ -283,11 +284,11 @@ impl BlockCollection {
transactions_root: info.transactions_root().clone(),
uncles: info.uncles_hash().clone(),
};
if header_id.transactions_root == rlp::SHA3_NULL_RLP && header_id.uncles == rlp::SHA3_EMPTY_LIST_RLP {
if header_id.transactions_root == sha3::SHA3_NULL_RLP && header_id.uncles == sha3::SHA3_EMPTY_LIST_RLP {
// empty body, just mark as downloaded
let mut body_stream = RlpStream::new_list(2);
body_stream.append_raw(&rlp::EMPTY_LIST_RLP, 1);
body_stream.append_raw(&rlp::EMPTY_LIST_RLP, 1);
body_stream.append_raw(&::rlp::EMPTY_LIST_RLP, 1);
body_stream.append_raw(&::rlp::EMPTY_LIST_RLP, 1);
block.body = Some(body_stream.out());
}
else {
@ -337,6 +338,7 @@ mod test {
use ethcore::views::HeaderView;
use ethcore::header::BlockNumber;
use util::*;
use rlp::*;
fn is_empty(bc: &BlockCollection) -> bool {
bc.heads.is_empty() &&

View File

@ -88,6 +88,7 @@
///
use util::*;
use rlp::*;
use network::*;
use std::mem::{replace};
use ethcore::views::{HeaderView, BlockView};
@ -1531,6 +1532,7 @@ mod tests {
use super::*;
use ::SyncConfig;
use util::*;
use rlp::*;
use super::{PeerInfo, PeerAsking};
use ethcore::views::BlockView;
use ethcore::header::*;
@ -1548,8 +1550,8 @@ mod tests {
let mut rlp = RlpStream::new_list(3);
rlp.append(&header);
rlp.append_raw(&rlp::EMPTY_LIST_RLP, 1);
rlp.append_raw(&rlp::EMPTY_LIST_RLP, 1);
rlp.append_raw(&::rlp::EMPTY_LIST_RLP, 1);
rlp.append_raw(&::rlp::EMPTY_LIST_RLP, 1);
rlp.out()
}

View File

@ -34,7 +34,6 @@
//! extern crate ethcore;
//! extern crate ethsync;
//! use std::env;
//! use std::sync::Arc;
//! use io::IoChannel;
//! use ethcore::client::{Client, ClientConfig};
//! use ethsync::{EthSync, SyncConfig, ManageNetwork, NetworkConfiguration};
@ -62,22 +61,24 @@
//! }
//! ```
#[macro_use]
extern crate log;
#[macro_use]
extern crate ethcore_util as util;
extern crate ethcore_network as network;
extern crate ethcore_io as io;
extern crate ethcore;
extern crate env_logger;
extern crate time;
extern crate rand;
extern crate semver;
extern crate parking_lot;
extern crate rlp;
#[macro_use]
extern crate log;
#[macro_use]
extern crate ethcore_util as util;
#[macro_use]
extern crate heapsize;
#[macro_use]
extern crate ethcore_ipc as ipc;
extern crate semver;
extern crate parking_lot;
mod chain;
mod blocks;

View File

@ -25,6 +25,7 @@ ethcore-util = { path = ".." }
ethcore-devtools = { path = "../../devtools" }
ethkey = { path = "../../ethkey" }
ethcrypto = { path = "../../ethcrypto" }
rlp = { path = "../rlp" }
[features]
default = []

View File

@ -23,7 +23,7 @@ use mio::tcp::*;
use util::hash::*;
use util::sha3::*;
use util::bytes::*;
use util::rlp::*;
use rlp::*;
use std::io::{self, Cursor, Read, Write};
use error::*;
use io::{IoContext, StreamToken};

View File

@ -24,7 +24,7 @@ use mio::udp::*;
use util::sha3::*;
use time;
use util::hash::*;
use util::rlp::*;
use rlp::*;
use node_table::*;
use error::NetworkError;
use io::{StreamToken, IoContext};

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
use io::IoError;
use util::rlp::*;
use rlp::*;
use util::UtilError;
use std::fmt;
use ethkey::Error as KeyError;

View File

@ -18,9 +18,9 @@ use std::sync::Arc;
use rand::random;
use mio::tcp::*;
use util::hash::*;
use util::rlp::*;
use util::sha3::Hashable;
use util::bytes::Bytes;
use rlp::*;
use connection::{Connection};
use host::{HostInfo};
use node_table::NodeId;

View File

@ -29,8 +29,8 @@ use mio::*;
use mio::tcp::*;
use util::hash::*;
use util::Hashable;
use util::rlp::*;
use util::version;
use rlp::*;
use session::{Session, SessionData};
use error::*;
use io::*;

View File

@ -54,9 +54,6 @@
//! }
//! ```
#[macro_use]
extern crate log;
extern crate ethcore_io as io;
extern crate ethcore_util as util;
extern crate parking_lot;
@ -72,6 +69,11 @@ extern crate libc;
extern crate slab;
extern crate ethkey;
extern crate ethcrypto as crypto;
extern crate rlp;
#[macro_use]
extern crate log;
#[cfg(test)]
extern crate ethcore_devtools as devtools;

View File

@ -26,8 +26,8 @@ use std::fmt;
use std::fs;
use std::io::{Read, Write};
use util::hash::*;
use util::rlp::*;
use util::UtilError;
use rlp::*;
use time::Tm;
use error::NetworkError;
use discovery::{TableUpdates, NodeEntry};

View File

@ -19,8 +19,8 @@ use std::io;
use std::sync::*;
use mio::*;
use mio::tcp::*;
use util::rlp::*;
use util::hash::*;
use rlp::*;
use connection::{EncryptedConnection, Packet, Connection};
use handshake::Handshake;
use io::{IoContext, StreamToken};