Merge with latest master
This commit is contained in:
commit
6ec282fe98
43
Cargo.lock
generated
43
Cargo.lock
generated
@ -3,7 +3,7 @@ name = "parity"
|
|||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)",
|
"ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)",
|
||||||
"daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
"docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -130,23 +130,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clippy"
|
name = "clippy"
|
||||||
version = "0.0.71"
|
version = "0.0.76"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clippy_lints 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clippy_lints 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quine-mc_cluskey 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"unicode-normalization 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clippy_lints"
|
name = "clippy_lints"
|
||||||
version = "0.0.71"
|
version = "0.0.76"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"quine-mc_cluskey 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"quine-mc_cluskey 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"regex-syntax 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -256,7 +251,7 @@ name = "ethcore"
|
|||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ethash 1.2.0",
|
"ethash 1.2.0",
|
||||||
@ -280,7 +275,7 @@ dependencies = [
|
|||||||
name = "ethcore-dapps"
|
name = "ethcore-dapps"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ethcore-rpc 1.2.0",
|
"ethcore-rpc 1.2.0",
|
||||||
"ethcore-util 1.2.0",
|
"ethcore-util 1.2.0",
|
||||||
"hyper 0.9.3 (git+https://github.com/ethcore/hyper)",
|
"hyper 0.9.3 (git+https://github.com/ethcore/hyper)",
|
||||||
@ -293,7 +288,7 @@ dependencies = [
|
|||||||
"parity-dapps-dao 0.4.0 (git+https://github.com/ethcore/parity-dapps-dao-rs.git)",
|
"parity-dapps-dao 0.4.0 (git+https://github.com/ethcore/parity-dapps-dao-rs.git)",
|
||||||
"parity-dapps-makerotc 0.3.0 (git+https://github.com/ethcore/parity-dapps-makerotc-rs.git)",
|
"parity-dapps-makerotc 0.3.0 (git+https://github.com/ethcore/parity-dapps-makerotc-rs.git)",
|
||||||
"parity-dapps-status 0.5.0 (git+https://github.com/ethcore/parity-dapps-status-rs.git)",
|
"parity-dapps-status 0.5.0 (git+https://github.com/ethcore/parity-dapps-status-rs.git)",
|
||||||
"parity-dapps-wallet 0.6.0 (git+https://github.com/ethcore/parity-dapps-wallet-rs.git)",
|
"parity-dapps-wallet 0.6.1 (git+https://github.com/ethcore/parity-dapps-wallet-rs.git)",
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_codegen 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -344,7 +339,7 @@ dependencies = [
|
|||||||
name = "ethcore-rpc"
|
name = "ethcore-rpc"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ethash 1.2.0",
|
"ethash 1.2.0",
|
||||||
"ethcore 1.2.0",
|
"ethcore 1.2.0",
|
||||||
"ethcore-devtools 1.2.0",
|
"ethcore-devtools 1.2.0",
|
||||||
@ -367,7 +362,7 @@ dependencies = [
|
|||||||
name = "ethcore-signer"
|
name = "ethcore-signer"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ethcore-rpc 1.2.0",
|
"ethcore-rpc 1.2.0",
|
||||||
"ethcore-util 1.2.0",
|
"ethcore-util 1.2.0",
|
||||||
@ -386,7 +381,7 @@ dependencies = [
|
|||||||
"arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
"arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bigint 0.1.0",
|
"bigint 0.1.0",
|
||||||
"chrono 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
"chrono 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -431,7 +426,7 @@ dependencies = [
|
|||||||
name = "ethsync"
|
name = "ethsync"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clippy 0.0.71 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ethcore 1.2.0",
|
"ethcore 1.2.0",
|
||||||
"ethcore-util 1.2.0",
|
"ethcore-util 1.2.0",
|
||||||
@ -606,7 +601,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "jsonrpc-http-server"
|
name = "jsonrpc-http-server"
|
||||||
version = "5.1.0"
|
version = "5.1.0"
|
||||||
source = "git+https://github.com/ethcore/jsonrpc-http-server.git#77dcac785c02c3a7622d36aa635ee80d63d0b20c"
|
source = "git+https://github.com/ethcore/jsonrpc-http-server.git#6117b1d77b5a60d6fa2dc884f12aa7f5fd4585ca"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hyper 0.9.3 (git+https://github.com/ethcore/hyper)",
|
"hyper 0.9.3 (git+https://github.com/ethcore/hyper)",
|
||||||
"jsonrpc-core 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"jsonrpc-core 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -901,7 +896,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-dapps-builtins"
|
name = "parity-dapps-builtins"
|
||||||
version = "0.5.1"
|
version = "0.5.1"
|
||||||
source = "git+https://github.com/ethcore/parity-dapps-builtins-rs.git#d3c95d62ffaa57016b162a9a9f0e6dd629dab423"
|
source = "git+https://github.com/ethcore/parity-dapps-builtins-rs.git#b3970ff4686a12321365cfafba6552bfaa2e7874"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)",
|
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)",
|
||||||
]
|
]
|
||||||
@ -909,7 +904,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-dapps-dao"
|
name = "parity-dapps-dao"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "git+https://github.com/ethcore/parity-dapps-dao-rs.git#18f4b839b20fbdf8e0d163e14d25aafee603ac4b"
|
source = "git+https://github.com/ethcore/parity-dapps-dao-rs.git#dd6b9ca7c18fbfa714183a4f570bd75b8391c13d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)",
|
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)",
|
||||||
]
|
]
|
||||||
@ -917,7 +912,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-dapps-makerotc"
|
name = "parity-dapps-makerotc"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
source = "git+https://github.com/ethcore/parity-dapps-makerotc-rs.git#7b771f217a3eefeb9a976c7ed470ca49fd9a9daa"
|
source = "git+https://github.com/ethcore/parity-dapps-makerotc-rs.git#33568ac7209aa765c498bb2322e848f552656303"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)",
|
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)",
|
||||||
]
|
]
|
||||||
@ -932,8 +927,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-dapps-wallet"
|
name = "parity-dapps-wallet"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
source = "git+https://github.com/ethcore/parity-dapps-wallet-rs.git#ad23b093d47527333a262c95e6fb20a97d15d6e6"
|
source = "git+https://github.com/ethcore/parity-dapps-wallet-rs.git#8923d4c73359c75ce04f0639bbcde46adb846b81"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)",
|
"parity-dapps 0.3.0 (git+https://github.com/ethcore/parity-dapps-rs.git)",
|
||||||
]
|
]
|
||||||
@ -941,7 +936,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-minimal-sysui"
|
name = "parity-minimal-sysui"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/ethcore/parity-dapps-minimal-sysui-rs.git#cb27ae09ee18773ccca6ba2ac74fa3128047a652"
|
source = "git+https://github.com/ethcore/parity-dapps-minimal-sysui-rs.git#4c704913f671060bb0e43b5ce4a68d02281115d5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "phf"
|
name = "phf"
|
||||||
|
@ -23,7 +23,7 @@ daemonize = "0.2"
|
|||||||
num_cpus = "0.2"
|
num_cpus = "0.2"
|
||||||
number_prefix = "0.2"
|
number_prefix = "0.2"
|
||||||
rpassword = "0.2.1"
|
rpassword = "0.2.1"
|
||||||
clippy = { version = "0.0.71", optional = true}
|
clippy = { version = "0.0.76", optional = true}
|
||||||
ethcore = { path = "ethcore" }
|
ethcore = { path = "ethcore" }
|
||||||
ethcore-util = { path = "util" }
|
ethcore-util = { path = "util" }
|
||||||
ethsync = { path = "sync" }
|
ethsync = { path = "sync" }
|
||||||
|
@ -28,7 +28,7 @@ parity-dapps-wallet = { git = "https://github.com/ethcore/parity-dapps-wallet-rs
|
|||||||
parity-dapps-dao = { git = "https://github.com/ethcore/parity-dapps-dao-rs.git", version = "0.4.0", optional = true }
|
parity-dapps-dao = { git = "https://github.com/ethcore/parity-dapps-dao-rs.git", version = "0.4.0", optional = true }
|
||||||
parity-dapps-makerotc = { git = "https://github.com/ethcore/parity-dapps-makerotc-rs.git", version = "0.3.0", optional = true }
|
parity-dapps-makerotc = { git = "https://github.com/ethcore/parity-dapps-makerotc-rs.git", version = "0.3.0", optional = true }
|
||||||
mime_guess = { version = "1.6.1" }
|
mime_guess = { version = "1.6.1" }
|
||||||
clippy = { version = "0.0.71", optional = true}
|
clippy = { version = "0.0.76", optional = true}
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
serde_codegen = { version = "0.7.0", optional = true }
|
serde_codegen = { version = "0.7.0", optional = true }
|
||||||
|
@ -22,7 +22,7 @@ ethcore-util = { path = "../util" }
|
|||||||
evmjit = { path = "../evmjit", optional = true }
|
evmjit = { path = "../evmjit", optional = true }
|
||||||
ethash = { path = "../ethash" }
|
ethash = { path = "../ethash" }
|
||||||
num_cpus = "0.2"
|
num_cpus = "0.2"
|
||||||
clippy = { version = "0.0.71", optional = true}
|
clippy = { version = "0.0.76", optional = true}
|
||||||
crossbeam = "0.2.9"
|
crossbeam = "0.2.9"
|
||||||
lazy_static = "0.1"
|
lazy_static = "0.1"
|
||||||
ethcore-devtools = { path = "../devtools" }
|
ethcore-devtools = { path = "../devtools" }
|
||||||
|
@ -793,18 +793,16 @@ impl<V> BlockChainClient for Client<V> where V: Verifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<V> MiningBlockChainClient for Client<V> where V: Verifier {
|
impl<V> MiningBlockChainClient for Client<V> where V: Verifier {
|
||||||
fn prepare_sealing(&self, author: Address, gas_floor_target: U256, extra_data: Bytes, transactions: Vec<SignedTransaction>)
|
fn prepare_open_block(&self, author: Address, gas_floor_target: U256, extra_data: Bytes) -> OpenBlock {
|
||||||
-> (Option<ClosedBlock>, HashSet<H256>) {
|
let engine = self.engine.deref().deref();
|
||||||
let engine = &**self.engine;
|
|
||||||
let h = self.chain.best_block_hash();
|
let h = self.chain.best_block_hash();
|
||||||
let mut invalid_transactions = HashSet::new();
|
|
||||||
|
|
||||||
let mut b = OpenBlock::new(
|
let mut open_block = OpenBlock::new(
|
||||||
engine,
|
engine,
|
||||||
&self.vm_factory,
|
&self.vm_factory,
|
||||||
false, // TODO: this will need to be parameterised once we want to do immediate mining insertion.
|
false, // TODO: this will need to be parameterised once we want to do immediate mining insertion.
|
||||||
self.state_db.lock().unwrap().boxed_clone(),
|
self.state_db.lock().unwrap().boxed_clone(),
|
||||||
match self.chain.block_header(&h) { Some(ref x) => x, None => { return (None, invalid_transactions) } },
|
&self.chain.block_header(&h).expect("h is best block hash: so it's header must exist: qed"),
|
||||||
self.build_last_hashes(h.clone()),
|
self.build_last_hashes(h.clone()),
|
||||||
author,
|
author,
|
||||||
gas_floor_target,
|
gas_floor_target,
|
||||||
@ -819,44 +817,10 @@ impl<V> MiningBlockChainClient for Client<V> where V: Verifier {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.take(engine.maximum_uncle_count())
|
.take(engine.maximum_uncle_count())
|
||||||
.foreach(|h| {
|
.foreach(|h| {
|
||||||
b.push_uncle(h).unwrap();
|
open_block.push_uncle(h).unwrap();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add transactions
|
open_block
|
||||||
let block_number = b.block().header().number();
|
|
||||||
let min_tx_gas = U256::from(self.engine.schedule(&b.env_info()).tx_gas);
|
|
||||||
|
|
||||||
for tx in transactions {
|
|
||||||
// Push transaction to block
|
|
||||||
let hash = tx.hash();
|
|
||||||
let import = b.push_transaction(tx, None);
|
|
||||||
|
|
||||||
match import {
|
|
||||||
Err(Error::Execution(ExecutionError::BlockGasLimitReached { gas_limit, gas_used, .. })) => {
|
|
||||||
trace!(target: "miner", "Skipping adding transaction to block because of gas limit: {:?}", hash);
|
|
||||||
// Exit early if gas left is smaller then min_tx_gas
|
|
||||||
if gas_limit - gas_used < min_tx_gas {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Err(e) => {
|
|
||||||
invalid_transactions.insert(hash);
|
|
||||||
trace!(target: "miner",
|
|
||||||
"Error adding transaction to block: number={}. transaction_hash={:?}, Error: {:?}",
|
|
||||||
block_number, hash, e);
|
|
||||||
},
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// And close
|
|
||||||
let b = b.close();
|
|
||||||
trace!(target: "miner", "Sealing: number={}, hash={}, diff={}",
|
|
||||||
b.block().header().number(),
|
|
||||||
b.hash(),
|
|
||||||
b.block().header().difficulty()
|
|
||||||
);
|
|
||||||
(Some(b), invalid_transactions)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_seal(&self, block: LockedBlock, seal: Vec<Bytes>) -> Result<SealedBlock, LockedBlock> {
|
fn try_seal(&self, block: LockedBlock, seal: Vec<Bytes>) -> Result<SealedBlock, LockedBlock> {
|
||||||
|
@ -31,14 +31,13 @@ pub use self::trace::Filter as TraceFilter;
|
|||||||
pub use executive::{Executed, Executive, TransactOptions};
|
pub use executive::{Executed, Executive, TransactOptions};
|
||||||
pub use env_info::{LastHashes, EnvInfo};
|
pub use env_info::{LastHashes, EnvInfo};
|
||||||
|
|
||||||
use std::collections::HashSet;
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use util::bytes::Bytes;
|
use util::bytes::Bytes;
|
||||||
use util::hash::{Address, H256, H2048};
|
use util::hash::{Address, H256, H2048};
|
||||||
use util::numbers::U256;
|
use util::numbers::U256;
|
||||||
use blockchain::TreeRoute;
|
use blockchain::TreeRoute;
|
||||||
use block_queue::BlockQueueInfo;
|
use block_queue::BlockQueueInfo;
|
||||||
use block::{ClosedBlock, LockedBlock, SealedBlock};
|
use block::{LockedBlock, SealedBlock, OpenBlock};
|
||||||
use header::{BlockNumber, Header};
|
use header::{BlockNumber, Header};
|
||||||
use transaction::{LocalizedTransaction, SignedTransaction};
|
use transaction::{LocalizedTransaction, SignedTransaction};
|
||||||
use log_entry::LocalizedLogEntry;
|
use log_entry::LocalizedLogEntry;
|
||||||
@ -206,7 +205,7 @@ pub trait MiningBlockChainClient : BlockChainClient {
|
|||||||
/// Attempts to seal given block. Returns `SealedBlock` on success and the same block in case of error.
|
/// Attempts to seal given block. Returns `SealedBlock` on success and the same block in case of error.
|
||||||
fn try_seal(&self, block: LockedBlock, seal: Vec<Bytes>) -> Result<SealedBlock, LockedBlock>;
|
fn try_seal(&self, block: LockedBlock, seal: Vec<Bytes>) -> Result<SealedBlock, LockedBlock>;
|
||||||
|
|
||||||
/// Returns ClosedBlock prepared for sealing.
|
/// Returns OpenBlock prepared for closing.
|
||||||
fn prepare_sealing(&self, author: Address, gas_floor_target: U256, extra_data: Bytes, transactions: Vec<SignedTransaction>)
|
fn prepare_open_block(&self, author: Address, gas_floor_target: U256, extra_data: Bytes)
|
||||||
-> (Option<ClosedBlock>, HashSet<H256>);
|
-> OpenBlock;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ use evm::Factory as EvmFactory;
|
|||||||
use miner::{Miner, MinerService};
|
use miner::{Miner, MinerService};
|
||||||
|
|
||||||
use block_queue::BlockQueueInfo;
|
use block_queue::BlockQueueInfo;
|
||||||
use block::{SealedBlock, ClosedBlock, LockedBlock};
|
use block::{SealedBlock, LockedBlock, OpenBlock};
|
||||||
use executive::Executed;
|
use executive::Executed;
|
||||||
use error::{ExecutionError};
|
use error::{ExecutionError};
|
||||||
use trace::LocalizedTrace;
|
use trace::LocalizedTrace;
|
||||||
@ -245,8 +245,8 @@ impl MiningBlockChainClient for TestBlockChainClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn prepare_sealing(&self, _author: Address, _gas_floor_target: U256, _extra_data: Bytes, _transactions: Vec<SignedTransaction>) -> (Option<ClosedBlock>, HashSet<H256>) {
|
fn prepare_open_block(&self, _author: Address, _gas_floor_target: U256, _extra_data: Bytes) -> OpenBlock {
|
||||||
(None, HashSet::new())
|
unimplemented!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,22 +117,30 @@ impl Miner {
|
|||||||
// otherwise, leave everything alone.
|
// otherwise, leave everything alone.
|
||||||
// otherwise, author a fresh block.
|
// otherwise, author a fresh block.
|
||||||
*/
|
*/
|
||||||
|
let mut open_block = match sealing_work.pop_if(|b| b.block().fields().header.parent_hash() == &best_hash) {
|
||||||
let (b, invalid_transactions) = match sealing_work.pop_if(|b| b.block().fields().header.parent_hash() == &best_hash) {
|
|
||||||
Some(old_block) => {
|
Some(old_block) => {
|
||||||
trace!(target: "miner", "Already have previous work; updating and returning");
|
trace!(target: "miner", "Already have previous work; updating and returning");
|
||||||
// add transactions to old_block
|
// add transactions to old_block
|
||||||
let e = self.engine();
|
let e = self.engine();
|
||||||
let mut invalid_transactions = HashSet::new();
|
old_block.reopen(e, chain.vm_factory())
|
||||||
let mut block = old_block.reopen(e, chain.vm_factory());
|
}
|
||||||
let block_number = block.block().fields().header.number();
|
None => {
|
||||||
|
// block not found - create it.
|
||||||
|
trace!(target: "miner", "No existing work - making new block");
|
||||||
|
chain.prepare_open_block(
|
||||||
|
self.author(),
|
||||||
|
self.gas_floor_target(),
|
||||||
|
self.extra_data()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut invalid_transactions = HashSet::new();
|
||||||
|
let block_number = open_block.block().fields().header.number();
|
||||||
// TODO: push new uncles, too.
|
// TODO: push new uncles, too.
|
||||||
// TODO: refactor with chain.prepare_sealing
|
|
||||||
for tx in transactions {
|
for tx in transactions {
|
||||||
let hash = tx.hash();
|
let hash = tx.hash();
|
||||||
let res = block.push_transaction(tx, None);
|
match open_block.push_transaction(tx, None) {
|
||||||
match res {
|
|
||||||
Err(Error::Execution(ExecutionError::BlockGasLimitReached { gas_limit, gas_used, .. })) => {
|
Err(Error::Execution(ExecutionError::BlockGasLimitReached { gas_limit, gas_used, .. })) => {
|
||||||
trace!(target: "miner", "Skipping adding transaction to block because of gas limit: {:?}", hash);
|
trace!(target: "miner", "Skipping adding transaction to block because of gas limit: {:?}", hash);
|
||||||
// Exit early if gas left is smaller then min_tx_gas
|
// Exit early if gas left is smaller then min_tx_gas
|
||||||
@ -151,28 +159,19 @@ impl Miner {
|
|||||||
_ => {} // imported ok
|
_ => {} // imported ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(Some(block.close()), invalid_transactions)
|
|
||||||
}
|
let block = open_block.close();
|
||||||
None => {
|
|
||||||
// block not found - create it.
|
|
||||||
trace!(target: "miner", "No existing work - making new block");
|
|
||||||
chain.prepare_sealing(
|
|
||||||
self.author(),
|
|
||||||
self.gas_floor_target(),
|
|
||||||
self.extra_data(),
|
|
||||||
transactions,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let mut queue = self.transaction_queue.lock().unwrap();
|
let mut queue = self.transaction_queue.lock().unwrap();
|
||||||
let fetch_account = |a: &Address| AccountDetails {
|
let fetch_account = |a: &Address| AccountDetails {
|
||||||
nonce: chain.latest_nonce(a),
|
nonce: chain.latest_nonce(a),
|
||||||
balance: chain.latest_balance(a),
|
balance: chain.latest_balance(a),
|
||||||
};
|
};
|
||||||
|
|
||||||
for hash in invalid_transactions.into_iter() {
|
for hash in invalid_transactions.into_iter() {
|
||||||
queue.remove_invalid(&hash, &fetch_account);
|
queue.remove_invalid(&hash, &fetch_account);
|
||||||
}
|
}
|
||||||
if let Some(block) = b {
|
|
||||||
if !block.transactions().is_empty() {
|
if !block.transactions().is_empty() {
|
||||||
trace!(target: "miner", "prepare_sealing: block has transaction - attempting internal seal.");
|
trace!(target: "miner", "prepare_sealing: block has transaction - attempting internal seal.");
|
||||||
// block with transactions - see if we can seal immediately.
|
// block with transactions - see if we can seal immediately.
|
||||||
@ -200,7 +199,7 @@ impl Miner {
|
|||||||
trace!(target: "miner", "Pushing a new, refreshed or borrowed pending {}...", block.block().fields().header.hash());
|
trace!(target: "miner", "Pushing a new, refreshed or borrowed pending {}...", block.block().fields().header.hash());
|
||||||
sealing_work.push(block);
|
sealing_work.push(block);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
trace!(target: "miner", "prepare_sealing: leaving (last={:?})", sealing_work.peek_last_ref().map(|b| b.block().fields().header.hash()));
|
trace!(target: "miner", "prepare_sealing: leaving (last={:?})", sealing_work.peek_last_ref().map(|b| b.block().fields().header.hash()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ fn can_mine() {
|
|||||||
let client_result = get_test_client_with_blocks(vec![dummy_blocks[0].clone()]);
|
let client_result = get_test_client_with_blocks(vec![dummy_blocks[0].clone()]);
|
||||||
let client = client_result.reference();
|
let client = client_result.reference();
|
||||||
|
|
||||||
let b = client.prepare_sealing(Address::default(), 31415926.into(), vec![], vec![]).0.unwrap();
|
let b = client.prepare_open_block(Address::default(), 31415926.into(), vec![]).close();
|
||||||
|
|
||||||
assert_eq!(*b.block().header().parent_hash(), BlockView::new(&dummy_blocks[0]).header_view().sha3());
|
assert_eq!(*b.block().header().parent_hash(), BlockView::new(&dummy_blocks[0]).header_view().sha3());
|
||||||
assert!(client.try_seal(b.lock(), vec![]).is_ok());
|
assert!(client.try_seal(b.lock(), vec![]).is_ok());
|
||||||
|
@ -15,7 +15,7 @@ with-syntex = ["quasi/with-syntex", "quasi_codegen", "quasi_codegen/with-syntex"
|
|||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
quasi_codegen = { version = "0.11", optional = true }
|
quasi_codegen = { version = "0.11", optional = true }
|
||||||
syntex = { version = "*", optional = true }
|
syntex = { version = "0.33", optional = true }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
aster = { version = "0.17", default-features = false }
|
aster = { version = "0.17", default-features = false }
|
||||||
|
@ -89,7 +89,7 @@ fn serialize_item(
|
|||||||
let (size_expr, read_expr, write_expr) =
|
let (size_expr, read_expr, write_expr) =
|
||||||
(binary_expressions.size, binary_expressions.read, binary_expressions.write);
|
(binary_expressions.size, binary_expressions.read, binary_expressions.write);
|
||||||
|
|
||||||
Ok(quote_item!(cx,
|
match quote_item!(cx,
|
||||||
impl $generics ::ipc::BinaryConvertable for $ty $where_clause {
|
impl $generics ::ipc::BinaryConvertable for $ty $where_clause {
|
||||||
fn size(&self) -> usize {
|
fn size(&self) -> usize {
|
||||||
$size_expr
|
$size_expr
|
||||||
@ -106,8 +106,16 @@ fn serialize_item(
|
|||||||
fn len_params() -> usize {
|
fn len_params() -> usize {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
{
|
||||||
|
Some(item) => Ok(item),
|
||||||
|
None => {
|
||||||
|
cx.span_err(
|
||||||
|
item.span,
|
||||||
|
"syntax error expanding serialization implementation");
|
||||||
|
Err(Error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
).unwrap())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unreachable_code)]
|
#[allow(unreachable_code)]
|
||||||
|
@ -19,20 +19,20 @@ extern crate ethcore_ipc_codegen as codegen;
|
|||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::process::exit;
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let out_dir = env::var_os("OUT_DIR").unwrap();
|
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||||
|
|
||||||
// ipc pass
|
// rpc pass
|
||||||
{
|
if {
|
||||||
let src = Path::new("nested.rs.in");
|
let src = Path::new("nested.rs.in");
|
||||||
let dst = Path::new(&out_dir).join("nested_ipc.rs");
|
let dst = Path::new(&out_dir).join("nested_ipc.rs");
|
||||||
let mut registry = syntex::Registry::new();
|
let mut registry = syntex::Registry::new();
|
||||||
codegen::register(&mut registry);
|
codegen::register(&mut registry);
|
||||||
registry.expand("", &src, &dst).unwrap();
|
registry.expand("", &src, &dst).is_ok()
|
||||||
}
|
}
|
||||||
|
// serialization pass
|
||||||
// serde pass
|
|
||||||
{
|
{
|
||||||
let src = Path::new(&out_dir).join("nested_ipc.rs");
|
let src = Path::new(&out_dir).join("nested_ipc.rs");
|
||||||
let dst = Path::new(&out_dir).join("nested_cg.rs");
|
let dst = Path::new(&out_dir).join("nested_cg.rs");
|
||||||
@ -41,16 +41,15 @@ pub fn main() {
|
|||||||
registry.expand("", &src, &dst).unwrap();
|
registry.expand("", &src, &dst).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ipc pass
|
// rpc pass
|
||||||
{
|
if {
|
||||||
let src = Path::new("service.rs.in");
|
let src = Path::new("service.rs.in");
|
||||||
let dst = Path::new(&out_dir).join("service_ipc.rs");
|
let dst = Path::new(&out_dir).join("service_ipc.rs");
|
||||||
let mut registry = syntex::Registry::new();
|
let mut registry = syntex::Registry::new();
|
||||||
codegen::register(&mut registry);
|
codegen::register(&mut registry);
|
||||||
registry.expand("", &src, &dst).unwrap();
|
registry.expand("", &src, &dst).is_ok()
|
||||||
}
|
}
|
||||||
|
// serialization pass
|
||||||
// serde pass
|
|
||||||
{
|
{
|
||||||
let src = Path::new(&out_dir).join("service_ipc.rs");
|
let src = Path::new(&out_dir).join("service_ipc.rs");
|
||||||
let dst = Path::new(&out_dir).join("service_cg.rs");
|
let dst = Path::new(&out_dir).join("service_cg.rs");
|
||||||
@ -59,13 +58,15 @@ pub fn main() {
|
|||||||
registry.expand("", &src, &dst).unwrap();
|
registry.expand("", &src, &dst).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rpc pass
|
||||||
// ipc pass
|
|
||||||
{
|
{
|
||||||
let src = Path::new("binary.rs.in");
|
let src = Path::new("binary.rs.in");
|
||||||
let dst = Path::new(&out_dir).join("binary.rs");
|
let dst = Path::new(&out_dir).join("binary.rs");
|
||||||
let mut registry = syntex::Registry::new();
|
let mut registry = syntex::Registry::new();
|
||||||
codegen::register(&mut registry);
|
codegen::register(&mut registry);
|
||||||
registry.expand("", &src, &dst).unwrap();
|
if let Err(err_msg) = registry.expand("", &src, &dst) {
|
||||||
|
println!("error: {}", err_msg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ rustc-serialize = "0.3"
|
|||||||
serde = "0.7.0"
|
serde = "0.7.0"
|
||||||
serde_json = "0.7.0"
|
serde_json = "0.7.0"
|
||||||
serde_macros = { version = "0.7.0", optional = true }
|
serde_macros = { version = "0.7.0", optional = true }
|
||||||
clippy = { version = "0.0.71", optional = true}
|
clippy = { version = "0.0.76", optional = true}
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
serde_codegen = { version = "0.7.0", optional = true }
|
serde_codegen = { version = "0.7.0", optional = true }
|
||||||
|
@ -360,6 +360,14 @@ impl Configuration {
|
|||||||
if self.args.flag_geth { self.geth_ipc_path() }
|
if self.args.flag_geth { self.geth_ipc_path() }
|
||||||
else { Configuration::replace_home(&self.args.flag_ipcpath.clone().unwrap_or(self.args.flag_ipc_path.clone())) }
|
else { Configuration::replace_home(&self.args.flag_ipcpath.clone().unwrap_or(self.args.flag_ipc_path.clone())) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn signer_port(&self) -> Option<u16> {
|
||||||
|
if self.args.flag_signer {
|
||||||
|
Some(self.args.flag_signer_port)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -201,7 +201,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
|||||||
let sync = EthSync::register(service.network(), sync_config, client.clone());
|
let sync = EthSync::register(service.network(), sync_config, client.clone());
|
||||||
|
|
||||||
let deps_for_rpc_apis = Arc::new(rpc_apis::Dependencies {
|
let deps_for_rpc_apis = Arc::new(rpc_apis::Dependencies {
|
||||||
signer_enabled: conf.args.flag_signer,
|
signer_port: conf.signer_port(),
|
||||||
signer_queue: Arc::new(rpc_apis::ConfirmationsQueue::default()),
|
signer_queue: Arc::new(rpc_apis::ConfirmationsQueue::default()),
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
sync: sync.clone(),
|
sync: sync.clone(),
|
||||||
@ -244,7 +244,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
|||||||
|
|
||||||
// Set up a signer
|
// Set up a signer
|
||||||
let signer_server = signer::start(signer::Configuration {
|
let signer_server = signer::start(signer::Configuration {
|
||||||
enabled: deps_for_rpc_apis.signer_enabled,
|
enabled: deps_for_rpc_apis.signer_port.is_some(),
|
||||||
port: conf.args.flag_signer_port,
|
port: conf.args.flag_signer_port,
|
||||||
signer_path: conf.directories().signer,
|
signer_path: conf.directories().signer,
|
||||||
}, signer::Dependencies {
|
}, signer::Dependencies {
|
||||||
|
@ -79,7 +79,7 @@ impl FromStr for Api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct Dependencies {
|
pub struct Dependencies {
|
||||||
pub signer_enabled: bool,
|
pub signer_port: Option<u16>,
|
||||||
pub signer_queue: Arc<ConfirmationsQueue>,
|
pub signer_queue: Arc<ConfirmationsQueue>,
|
||||||
pub client: Arc<Client>,
|
pub client: Arc<Client>,
|
||||||
pub sync: Arc<EthSync>,
|
pub sync: Arc<EthSync>,
|
||||||
@ -146,14 +146,14 @@ pub fn setup_rpc<T: Extendable>(server: T, deps: Arc<Dependencies>, apis: ApiSet
|
|||||||
server.add_delegate(EthClient::new(&deps.client, &deps.sync, &deps.secret_store, &deps.miner, &deps.external_miner).to_delegate());
|
server.add_delegate(EthClient::new(&deps.client, &deps.sync, &deps.secret_store, &deps.miner, &deps.external_miner).to_delegate());
|
||||||
server.add_delegate(EthFilterClient::new(&deps.client, &deps.miner).to_delegate());
|
server.add_delegate(EthFilterClient::new(&deps.client, &deps.miner).to_delegate());
|
||||||
|
|
||||||
if deps.signer_enabled {
|
if deps.signer_port.is_some() {
|
||||||
server.add_delegate(EthSigningQueueClient::new(&deps.signer_queue).to_delegate());
|
server.add_delegate(EthSigningQueueClient::new(&deps.signer_queue).to_delegate());
|
||||||
} else {
|
} else {
|
||||||
server.add_delegate(EthSigningUnsafeClient::new(&deps.client, &deps.secret_store, &deps.miner).to_delegate());
|
server.add_delegate(EthSigningUnsafeClient::new(&deps.client, &deps.secret_store, &deps.miner).to_delegate());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Api::Personal => {
|
Api::Personal => {
|
||||||
server.add_delegate(PersonalClient::new(&deps.secret_store, &deps.client, &deps.miner, deps.signer_enabled).to_delegate());
|
server.add_delegate(PersonalClient::new(&deps.secret_store, &deps.client, &deps.miner, deps.signer_port).to_delegate());
|
||||||
},
|
},
|
||||||
Api::Signer => {
|
Api::Signer => {
|
||||||
server.add_delegate(SignerClient::new(&deps.secret_store, &deps.client, &deps.miner, &deps.signer_queue).to_delegate());
|
server.add_delegate(SignerClient::new(&deps.secret_store, &deps.client, &deps.miner, &deps.signer_queue).to_delegate());
|
||||||
|
@ -23,7 +23,7 @@ ethcore-devtools = { path = "../devtools" }
|
|||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
transient-hashmap = "0.1"
|
transient-hashmap = "0.1"
|
||||||
serde_macros = { version = "0.7.0", optional = true }
|
serde_macros = { version = "0.7.0", optional = true }
|
||||||
clippy = { version = "0.0.71", optional = true}
|
clippy = { version = "0.0.76", optional = true}
|
||||||
json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" }
|
json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@ -75,7 +75,11 @@ impl RpcServer {
|
|||||||
/// Start http server asynchronously and returns result with `Server` handle on success or an error.
|
/// Start http server asynchronously and returns result with `Server` handle on success or an error.
|
||||||
pub fn start_http(&self, addr: &SocketAddr, cors_domains: Vec<String>) -> Result<Server, RpcServerError> {
|
pub fn start_http(&self, addr: &SocketAddr, cors_domains: Vec<String>) -> Result<Server, RpcServerError> {
|
||||||
let cors_domains = cors_domains.into_iter()
|
let cors_domains = cors_domains.into_iter()
|
||||||
.map(jsonrpc_http_server::AccessControlAllowOrigin::Value)
|
.map(|v| match v.as_str() {
|
||||||
|
"*" => jsonrpc_http_server::AccessControlAllowOrigin::Any,
|
||||||
|
"null" => jsonrpc_http_server::AccessControlAllowOrigin::Null,
|
||||||
|
v => jsonrpc_http_server::AccessControlAllowOrigin::Value(v.into()),
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
Server::start(addr, self.handler.clone(), cors_domains)
|
Server::start(addr, self.handler.clone(), cors_domains)
|
||||||
}
|
}
|
||||||
|
@ -31,18 +31,18 @@ pub struct PersonalClient<A, C, M>
|
|||||||
accounts: Weak<A>,
|
accounts: Weak<A>,
|
||||||
client: Weak<C>,
|
client: Weak<C>,
|
||||||
miner: Weak<M>,
|
miner: Weak<M>,
|
||||||
signer_enabled: bool,
|
signer_port: Option<u16>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A, C, M> PersonalClient<A, C, M>
|
impl<A, C, M> PersonalClient<A, C, M>
|
||||||
where A: AccountProvider, C: MiningBlockChainClient, M: MinerService {
|
where A: AccountProvider, C: MiningBlockChainClient, M: MinerService {
|
||||||
/// Creates new PersonalClient
|
/// Creates new PersonalClient
|
||||||
pub fn new(store: &Arc<A>, client: &Arc<C>, miner: &Arc<M>, signer_enabled: bool) -> Self {
|
pub fn new(store: &Arc<A>, client: &Arc<C>, miner: &Arc<M>, signer_port: Option<u16>) -> Self {
|
||||||
PersonalClient {
|
PersonalClient {
|
||||||
accounts: Arc::downgrade(store),
|
accounts: Arc::downgrade(store),
|
||||||
client: Arc::downgrade(client),
|
client: Arc::downgrade(client),
|
||||||
miner: Arc::downgrade(miner),
|
miner: Arc::downgrade(miner),
|
||||||
signer_enabled: signer_enabled,
|
signer_port: signer_port,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,7 +51,9 @@ impl<A: 'static, C: 'static, M: 'static> Personal for PersonalClient<A, C, M>
|
|||||||
where A: AccountProvider, C: MiningBlockChainClient, M: MinerService {
|
where A: AccountProvider, C: MiningBlockChainClient, M: MinerService {
|
||||||
|
|
||||||
fn signer_enabled(&self, _: Params) -> Result<Value, Error> {
|
fn signer_enabled(&self, _: Params) -> Result<Value, Error> {
|
||||||
to_value(&self.signer_enabled)
|
self.signer_port
|
||||||
|
.map(|v| to_value(&v))
|
||||||
|
.unwrap_or_else(|| to_value(&false))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn accounts(&self, _: Params) -> Result<Value, Error> {
|
fn accounts(&self, _: Params) -> Result<Value, Error> {
|
||||||
|
@ -49,11 +49,11 @@ fn miner_service() -> Arc<TestMinerService> {
|
|||||||
Arc::new(TestMinerService::default())
|
Arc::new(TestMinerService::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup() -> PersonalTester {
|
fn setup(signer: Option<u16>) -> PersonalTester {
|
||||||
let accounts = accounts_provider();
|
let accounts = accounts_provider();
|
||||||
let client = blockchain_client();
|
let client = blockchain_client();
|
||||||
let miner = miner_service();
|
let miner = miner_service();
|
||||||
let personal = PersonalClient::new(&accounts, &client, &miner, false);
|
let personal = PersonalClient::new(&accounts, &client, &miner, signer);
|
||||||
|
|
||||||
let io = IoHandler::new();
|
let io = IoHandler::new();
|
||||||
io.add_delegate(personal.to_delegate());
|
io.add_delegate(personal.to_delegate());
|
||||||
@ -71,7 +71,7 @@ fn setup() -> PersonalTester {
|
|||||||
#[test]
|
#[test]
|
||||||
fn should_return_false_if_signer_is_disabled() {
|
fn should_return_false_if_signer_is_disabled() {
|
||||||
// given
|
// given
|
||||||
let tester = setup();
|
let tester = setup(None);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
let request = r#"{"jsonrpc": "2.0", "method": "personal_signerEnabled", "params": [], "id": 1}"#;
|
let request = r#"{"jsonrpc": "2.0", "method": "personal_signerEnabled", "params": [], "id": 1}"#;
|
||||||
@ -82,9 +82,23 @@ fn should_return_false_if_signer_is_disabled() {
|
|||||||
assert_eq!(tester.io.handle_request(request), Some(response.to_owned()));
|
assert_eq!(tester.io.handle_request(request), Some(response.to_owned()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_return_port_number_if_signer_is_enabled() {
|
||||||
|
// given
|
||||||
|
let tester = setup(Some(8180));
|
||||||
|
|
||||||
|
// when
|
||||||
|
let request = r#"{"jsonrpc": "2.0", "method": "personal_signerEnabled", "params": [], "id": 1}"#;
|
||||||
|
let response = r#"{"jsonrpc":"2.0","result":8180,"id":1}"#;
|
||||||
|
|
||||||
|
|
||||||
|
// then
|
||||||
|
assert_eq!(tester.io.handle_request(request), Some(response.to_owned()));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn accounts() {
|
fn accounts() {
|
||||||
let tester = setup();
|
let tester = setup(None);
|
||||||
tester.accounts.accounts
|
tester.accounts.accounts
|
||||||
.write()
|
.write()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -98,7 +112,7 @@ fn accounts() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn new_account() {
|
fn new_account() {
|
||||||
let tester = setup();
|
let tester = setup(None);
|
||||||
let request = r#"{"jsonrpc": "2.0", "method": "personal_newAccount", "params": ["pass"], "id": 1}"#;
|
let request = r#"{"jsonrpc": "2.0", "method": "personal_newAccount", "params": ["pass"], "id": 1}"#;
|
||||||
|
|
||||||
let res = tester.io.handle_request(request);
|
let res = tester.io.handle_request(request);
|
||||||
@ -122,7 +136,7 @@ fn sign_and_send_transaction_with_invalid_password() {
|
|||||||
let account = TestAccount::new("password123");
|
let account = TestAccount::new("password123");
|
||||||
let address = account.address();
|
let address = account.address();
|
||||||
|
|
||||||
let tester = setup();
|
let tester = setup(None);
|
||||||
tester.accounts.accounts.write().unwrap().insert(address.clone(), account);
|
tester.accounts.accounts.write().unwrap().insert(address.clone(), account);
|
||||||
let request = r#"{
|
let request = r#"{
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
@ -148,7 +162,7 @@ fn sign_and_send_transaction() {
|
|||||||
let address = account.address();
|
let address = account.address();
|
||||||
let secret = account.secret.clone();
|
let secret = account.secret.clone();
|
||||||
|
|
||||||
let tester = setup();
|
let tester = setup(None);
|
||||||
tester.accounts.accounts.write().unwrap().insert(address.clone(), account);
|
tester.accounts.accounts.write().unwrap().insert(address.clone(), account);
|
||||||
let request = r#"{
|
let request = r#"{
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
|
@ -487,7 +487,7 @@ mod tests {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
let serialized = serde_json::to_string(&t).unwrap();
|
let serialized = serde_json::to_string(&t).unwrap();
|
||||||
assert_eq!(serialized, "{\"code\":[0,1,2,3],\"ops\":[{\"pc\":0,\"cost\":10,\"ex\":null,\"sub\":null},{\"pc\":1,\"cost\":11,\"ex\":{\"used\":10,\"push\":[\"0x45\"],\"mem\":null,\"store\":null},\"sub\":{\"code\":[0],\"ops\":[{\"pc\":0,\"cost\":0,\"ex\":{\"used\":10,\"push\":[\"0x2a\"],\"mem\":{\"off\":42,\"data\":[1,2,3]},\"store\":{\"key\":\"0x45\",\"val\":\"0x2a\"}},\"sub\":null}]}}]}");
|
assert_eq!(serialized, r#"{"code":[0,1,2,3],"ops":[{"pc":0,"cost":10,"ex":null,"sub":null},{"pc":1,"cost":11,"ex":{"used":10,"push":["0x45"],"mem":null,"store":null},"sub":{"code":[0],"ops":[{"pc":0,"cost":0,"ex":{"used":10,"push":["0x2a"],"mem":{"off":42,"data":[1,2,3]},"store":{"key":"0x45","val":"0x2a"}},"sub":null}]}}]}"#);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -509,7 +509,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
let serialized = serde_json::to_string(&t).unwrap();
|
let serialized = serde_json::to_string(&t).unwrap();
|
||||||
assert_eq!(serialized, "{\"0x000000000000000000000000000000000000002a\":{\"balance\":{\"=\":[]},\"nonce\":{\"+\":\"0x01\"},\"code\":{\"=\":[]},\"storage\":{\"0x000000000000000000000000000000000000000000000000000000000000002a\":{\"=\":[]}}},\"0x0000000000000000000000000000000000000045\":{\"balance\":{\"=\":[]},\"nonce\":{\"*\":{\"from\":\"0x01\",\"to\":\"0x00\"}},\"code\":{\"-\":\"0x60\"},\"storage\":{}}}");
|
assert_eq!(serialized, r#"{"0x000000000000000000000000000000000000002a":{"balance":{"=":[]},"nonce":{"+":"0x01"},"code":{"=":[]},"storage":{"0x000000000000000000000000000000000000000000000000000000000000002a":{"=":[]}}},"0x0000000000000000000000000000000000000045":{"balance":{"=":[]},"nonce":{"*":{"from":"0x01","to":"0x00"}},"code":{"-":"0x60"},"storage":{}}}"#);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -20,7 +20,7 @@ ethcore-util = { path = "../util" }
|
|||||||
ethcore-rpc = { path = "../rpc" }
|
ethcore-rpc = { path = "../rpc" }
|
||||||
parity-minimal-sysui = { git = "https://github.com/ethcore/parity-dapps-minimal-sysui-rs.git" }
|
parity-minimal-sysui = { git = "https://github.com/ethcore/parity-dapps-minimal-sysui-rs.git" }
|
||||||
|
|
||||||
clippy = { version = "0.0.71", optional = true}
|
clippy = { version = "0.0.76", optional = true}
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
dev = ["clippy"]
|
dev = ["clippy"]
|
||||||
|
@ -10,7 +10,7 @@ authors = ["Ethcore <admin@ethcore.io"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
ethcore-util = { path = "../util" }
|
ethcore-util = { path = "../util" }
|
||||||
ethcore = { path = "../ethcore" }
|
ethcore = { path = "../ethcore" }
|
||||||
clippy = { version = "0.0.71", optional = true}
|
clippy = { version = "0.0.76", optional = true}
|
||||||
log = "0.3"
|
log = "0.3"
|
||||||
env_logger = "0.3"
|
env_logger = "0.3"
|
||||||
time = "0.1.34"
|
time = "0.1.34"
|
||||||
|
@ -28,7 +28,7 @@ crossbeam = "0.2"
|
|||||||
slab = "0.2"
|
slab = "0.2"
|
||||||
sha3 = { path = "sha3" }
|
sha3 = { path = "sha3" }
|
||||||
serde = "0.7.0"
|
serde = "0.7.0"
|
||||||
clippy = { version = "0.0.71", optional = true}
|
clippy = { version = "0.0.76", optional = true}
|
||||||
json-tests = { path = "json-tests" }
|
json-tests = { path = "json-tests" }
|
||||||
igd = "0.4.2"
|
igd = "0.4.2"
|
||||||
ethcore-devtools = { path = "../devtools" }
|
ethcore-devtools = { path = "../devtools" }
|
||||||
|
@ -91,9 +91,9 @@ macro_rules! uint_overflowing_add_reg {
|
|||||||
#[cfg(all(asm_available, target_arch="x86_64"))]
|
#[cfg(all(asm_available, target_arch="x86_64"))]
|
||||||
macro_rules! uint_overflowing_add {
|
macro_rules! uint_overflowing_add {
|
||||||
(U256, $n_words: expr, $self_expr: expr, $other: expr) => ({
|
(U256, $n_words: expr, $self_expr: expr, $other: expr) => ({
|
||||||
let mut result: [u64; 4] = unsafe { mem::uninitialized() };
|
let mut result: [u64; $n_words] = unsafe { mem::uninitialized() };
|
||||||
let self_t: &[u64; 4] = unsafe { &mem::transmute($self_expr) };
|
let self_t: &[u64; $n_words] = &$self_expr.0;
|
||||||
let other_t: &[u64; 4] = unsafe { &mem::transmute($other) };
|
let other_t: &[u64; $n_words] = &$other.0;
|
||||||
|
|
||||||
let overflow: u8;
|
let overflow: u8;
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -114,9 +114,9 @@ macro_rules! uint_overflowing_add {
|
|||||||
(U256(result), overflow != 0)
|
(U256(result), overflow != 0)
|
||||||
});
|
});
|
||||||
(U512, $n_words: expr, $self_expr: expr, $other: expr) => ({
|
(U512, $n_words: expr, $self_expr: expr, $other: expr) => ({
|
||||||
let mut result: [u64; 8] = unsafe { mem::uninitialized() };
|
let mut result: [u64; $n_words] = unsafe { mem::uninitialized() };
|
||||||
let self_t: &[u64; 8] = unsafe { &mem::transmute($self_expr) };
|
let self_t: &[u64; $n_words] = &$self_expr.0;
|
||||||
let other_t: &[u64; 8] = unsafe { &mem::transmute($other) };
|
let other_t: &[u64; $n_words] = &$other.0;
|
||||||
|
|
||||||
let overflow: u8;
|
let overflow: u8;
|
||||||
|
|
||||||
@ -195,9 +195,9 @@ macro_rules! uint_overflowing_sub_reg {
|
|||||||
#[cfg(all(asm_available, target_arch="x86_64"))]
|
#[cfg(all(asm_available, target_arch="x86_64"))]
|
||||||
macro_rules! uint_overflowing_sub {
|
macro_rules! uint_overflowing_sub {
|
||||||
(U256, $n_words: expr, $self_expr: expr, $other: expr) => ({
|
(U256, $n_words: expr, $self_expr: expr, $other: expr) => ({
|
||||||
let mut result: [u64; 4] = unsafe { mem::uninitialized() };
|
let mut result: [u64; $n_words] = unsafe { mem::uninitialized() };
|
||||||
let self_t: &[u64; 4] = unsafe { &mem::transmute($self_expr) };
|
let self_t: &[u64; $n_words] = &$self_expr.0;
|
||||||
let other_t: &[u64; 4] = unsafe { &mem::transmute($other) };
|
let other_t: &[u64; $n_words] = &$other.0;
|
||||||
|
|
||||||
let overflow: u8;
|
let overflow: u8;
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -217,9 +217,9 @@ macro_rules! uint_overflowing_sub {
|
|||||||
(U256(result), overflow != 0)
|
(U256(result), overflow != 0)
|
||||||
});
|
});
|
||||||
(U512, $n_words: expr, $self_expr: expr, $other: expr) => ({
|
(U512, $n_words: expr, $self_expr: expr, $other: expr) => ({
|
||||||
let mut result: [u64; 8] = unsafe { mem::uninitialized() };
|
let mut result: [u64; $n_words] = unsafe { mem::uninitialized() };
|
||||||
let self_t: &[u64; 8] = unsafe { &mem::transmute($self_expr) };
|
let self_t: &[u64; $n_words] = &$self_expr.0;
|
||||||
let other_t: &[u64; 8] = unsafe { &mem::transmute($other) };
|
let other_t: &[u64; $n_words] = &$other.0;
|
||||||
|
|
||||||
let overflow: u8;
|
let overflow: u8;
|
||||||
|
|
||||||
@ -269,9 +269,9 @@ macro_rules! uint_overflowing_sub {
|
|||||||
#[cfg(all(asm_available, target_arch="x86_64"))]
|
#[cfg(all(asm_available, target_arch="x86_64"))]
|
||||||
macro_rules! uint_overflowing_mul {
|
macro_rules! uint_overflowing_mul {
|
||||||
(U256, $n_words: expr, $self_expr: expr, $other: expr) => ({
|
(U256, $n_words: expr, $self_expr: expr, $other: expr) => ({
|
||||||
let mut result: [u64; 4] = unsafe { mem::uninitialized() };
|
let mut result: [u64; $n_words] = unsafe { mem::uninitialized() };
|
||||||
let self_t: &[u64; 4] = unsafe { &mem::transmute($self_expr) };
|
let self_t: &[u64; $n_words] = &$self_expr.0;
|
||||||
let other_t: &[u64; 4] = unsafe { &mem::transmute($other) };
|
let other_t: &[u64; $n_words] = &$other.0;
|
||||||
|
|
||||||
let overflow: u64;
|
let overflow: u64;
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -548,6 +548,7 @@ pub trait Uint: Sized + Default + FromStr + From<u64> + fmt::Debug + fmt::Displa
|
|||||||
macro_rules! construct_uint {
|
macro_rules! construct_uint {
|
||||||
($name:ident, $n_words:expr) => (
|
($name:ident, $n_words:expr) => (
|
||||||
/// Little-endian large integer type
|
/// Little-endian large integer type
|
||||||
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||||
pub struct $name(pub [u64; $n_words]);
|
pub struct $name(pub [u64; $n_words]);
|
||||||
|
|
||||||
@ -1132,8 +1133,8 @@ impl U256 {
|
|||||||
/// No overflow possible
|
/// No overflow possible
|
||||||
#[cfg(all(asm_available, target_arch="x86_64"))]
|
#[cfg(all(asm_available, target_arch="x86_64"))]
|
||||||
pub fn full_mul(self, other: U256) -> U512 {
|
pub fn full_mul(self, other: U256) -> U512 {
|
||||||
let self_t: &[u64; 4] = unsafe { &mem::transmute(self) };
|
let self_t: &[u64; 4] = &self.0;
|
||||||
let other_t: &[u64; 4] = unsafe { &mem::transmute(other) };
|
let other_t: &[u64; 4] = &other.0;
|
||||||
let mut result: [u64; 8] = unsafe { mem::uninitialized() };
|
let mut result: [u64; 8] = unsafe { mem::uninitialized() };
|
||||||
unsafe {
|
unsafe {
|
||||||
asm!("
|
asm!("
|
||||||
|
@ -143,6 +143,7 @@ macro_rules! impl_hash {
|
|||||||
}
|
}
|
||||||
min
|
min
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_slice(src: &[u8]) -> Self {
|
fn from_slice(src: &[u8]) -> Self {
|
||||||
let mut r = Self::new();
|
let mut r = Self::new();
|
||||||
r.clone_from_slice(src);
|
r.clone_from_slice(src);
|
||||||
@ -150,24 +151,15 @@ macro_rules! impl_hash {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn copy_to(&self, dest: &mut[u8]) {
|
fn copy_to(&self, dest: &mut[u8]) {
|
||||||
unsafe {
|
|
||||||
let min = ::std::cmp::min($size, dest.len());
|
let min = ::std::cmp::min($size, dest.len());
|
||||||
::std::ptr::copy(self.0.as_ptr(), dest.as_mut_ptr(), min);
|
dest[..min].copy_from_slice(&self.0[..min]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn shift_bloomed<'a, T>(&'a mut self, b: &T) -> &'a mut Self where T: FixedHash {
|
fn shift_bloomed<'a, T>(&'a mut self, b: &T) -> &'a mut Self where T: FixedHash {
|
||||||
let bp: Self = b.bloom_part($size);
|
let bp: Self = b.bloom_part($size);
|
||||||
let new_self = &bp | self;
|
let new_self = &bp | self;
|
||||||
|
|
||||||
// impl |= instead
|
self.0 = new_self.0;
|
||||||
// TODO: that's done now!
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
use std::{mem, ptr};
|
|
||||||
ptr::copy(new_self.0.as_ptr(), self.0.as_mut_ptr(), mem::size_of::<Self>());
|
|
||||||
}
|
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +171,6 @@ macro_rules! impl_hash {
|
|||||||
let bloom_bits = m * 8;
|
let bloom_bits = m * 8;
|
||||||
let mask = bloom_bits - 1;
|
let mask = bloom_bits - 1;
|
||||||
let bloom_bytes = (log2(bloom_bits) + 7) / 8;
|
let bloom_bytes = (log2(bloom_bits) + 7) / 8;
|
||||||
//println!("bb: {}", bloom_bytes);
|
|
||||||
|
|
||||||
// must be a power of 2
|
// must be a power of 2
|
||||||
assert_eq!(m & (m - 1), 0);
|
assert_eq!(m & (m - 1), 0);
|
||||||
@ -316,14 +307,11 @@ macro_rules! impl_hash {
|
|||||||
#[cfg_attr(feature="dev", allow(expl_impl_clone_on_copy))]
|
#[cfg_attr(feature="dev", allow(expl_impl_clone_on_copy))]
|
||||||
impl Clone for $from {
|
impl Clone for $from {
|
||||||
fn clone(&self) -> $from {
|
fn clone(&self) -> $from {
|
||||||
unsafe {
|
let mut ret = $from::new();
|
||||||
use std::{mem, ptr};
|
ret.0.copy_from_slice(&self.0);
|
||||||
let mut ret: $from = mem::uninitialized();
|
|
||||||
ptr::copy(self.0.as_ptr(), ret.0.as_mut_ptr(), mem::size_of::<$from>());
|
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl PartialEq for $from {
|
impl PartialEq for $from {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
@ -404,16 +392,13 @@ macro_rules! impl_hash {
|
|||||||
type Output = $from;
|
type Output = $from;
|
||||||
|
|
||||||
fn bitor(self, rhs: Self) -> Self::Output {
|
fn bitor(self, rhs: Self) -> Self::Output {
|
||||||
unsafe {
|
let mut ret: $from = $from::default();
|
||||||
use std::mem;
|
|
||||||
let mut ret: $from = mem::uninitialized();
|
|
||||||
for i in 0..$size {
|
for i in 0..$size {
|
||||||
ret.0[i] = self.0[i] | rhs.0[i];
|
ret.0[i] = self.0[i] | rhs.0[i];
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Moving `BitOr`
|
/// Moving `BitOr`
|
||||||
impl BitOr for $from {
|
impl BitOr for $from {
|
||||||
@ -429,16 +414,13 @@ macro_rules! impl_hash {
|
|||||||
type Output = $from;
|
type Output = $from;
|
||||||
|
|
||||||
fn bitand(self, rhs: Self) -> Self::Output {
|
fn bitand(self, rhs: Self) -> Self::Output {
|
||||||
unsafe {
|
let mut ret: $from = $from::default();
|
||||||
use std::mem;
|
|
||||||
let mut ret: $from = mem::uninitialized();
|
|
||||||
for i in 0..$size {
|
for i in 0..$size {
|
||||||
ret.0[i] = self.0[i] & rhs.0[i];
|
ret.0[i] = self.0[i] & rhs.0[i];
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Moving `BitAnd`
|
/// Moving `BitAnd`
|
||||||
impl BitAnd for $from {
|
impl BitAnd for $from {
|
||||||
@ -454,16 +436,13 @@ macro_rules! impl_hash {
|
|||||||
type Output = $from;
|
type Output = $from;
|
||||||
|
|
||||||
fn bitxor(self, rhs: Self) -> Self::Output {
|
fn bitxor(self, rhs: Self) -> Self::Output {
|
||||||
unsafe {
|
let mut ret: $from = $from::default();
|
||||||
use std::mem;
|
|
||||||
let mut ret: $from = mem::uninitialized();
|
|
||||||
for i in 0..$size {
|
for i in 0..$size {
|
||||||
ret.0[i] = self.0[i] ^ rhs.0[i];
|
ret.0[i] = self.0[i] ^ rhs.0[i];
|
||||||
}
|
}
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Moving `BitXor`
|
/// Moving `BitXor`
|
||||||
impl BitXor for $from {
|
impl BitXor for $from {
|
||||||
@ -516,23 +495,19 @@ macro_rules! impl_hash {
|
|||||||
|
|
||||||
impl From<U256> for H256 {
|
impl From<U256> for H256 {
|
||||||
fn from(value: U256) -> H256 {
|
fn from(value: U256) -> H256 {
|
||||||
unsafe {
|
let mut ret = H256::new();
|
||||||
let mut ret: H256 = ::std::mem::uninitialized();
|
|
||||||
value.to_raw_bytes(&mut ret);
|
value.to_raw_bytes(&mut ret);
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> From<&'a U256> for H256 {
|
impl<'a> From<&'a U256> for H256 {
|
||||||
fn from(value: &'a U256) -> H256 {
|
fn from(value: &'a U256) -> H256 {
|
||||||
unsafe {
|
let mut ret: H256 = H256::new();
|
||||||
let mut ret: H256 = ::std::mem::uninitialized();
|
|
||||||
value.to_raw_bytes(&mut ret);
|
value.to_raw_bytes(&mut ret);
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl From<H256> for U256 {
|
impl From<H256> for U256 {
|
||||||
fn from(value: H256) -> U256 {
|
fn from(value: H256) -> U256 {
|
||||||
@ -548,53 +523,46 @@ impl<'a> From<&'a H256> for U256 {
|
|||||||
|
|
||||||
impl From<H256> for Address {
|
impl From<H256> for Address {
|
||||||
fn from(value: H256) -> Address {
|
fn from(value: H256) -> Address {
|
||||||
unsafe {
|
let mut ret = Address::new();
|
||||||
let mut ret: Address = ::std::mem::uninitialized();
|
ret.0.copy_from_slice(&value[12..32]);
|
||||||
::std::ptr::copy(value.as_ptr().offset(12), ret.as_mut_ptr(), 20);
|
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl From<H256> for H64 {
|
impl From<H256> for H64 {
|
||||||
fn from(value: H256) -> H64 {
|
fn from(value: H256) -> H64 {
|
||||||
unsafe {
|
let mut ret = H64::new();
|
||||||
let mut ret: H64 = ::std::mem::uninitialized();
|
ret.0.copy_from_slice(&value[20..28]);
|
||||||
::std::ptr::copy(value.as_ptr().offset(20), ret.as_mut_ptr(), 8);
|
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
impl<'a> From<&'a H256> for Address {
|
impl<'a> From<&'a H256> for Address {
|
||||||
fn from(value: &'a H256) -> Address {
|
fn from(value: &'a H256) -> Address {
|
||||||
unsafe {
|
let mut ret = Address::new();
|
||||||
let mut ret: Address = ::std::mem::uninitialized();
|
ret.0.copy_from_slice(&value[12..32]);
|
||||||
::std::ptr::copy(value.as_ptr().offset(12), ret.as_mut_ptr(), 20);
|
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
impl From<Address> for H256 {
|
impl From<Address> for H256 {
|
||||||
fn from(value: Address) -> H256 {
|
fn from(value: Address) -> H256 {
|
||||||
unsafe {
|
|
||||||
let mut ret = H256::new();
|
let mut ret = H256::new();
|
||||||
::std::ptr::copy(value.as_ptr(), ret.as_mut_ptr().offset(12), 20);
|
ret.0[12..32].copy_from_slice(&value);
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> From<&'a Address> for H256 {
|
impl<'a> From<&'a Address> for H256 {
|
||||||
fn from(value: &'a Address) -> H256 {
|
fn from(value: &'a Address) -> H256 {
|
||||||
unsafe {
|
|
||||||
let mut ret = H256::new();
|
let mut ret = H256::new();
|
||||||
::std::ptr::copy(value.as_ptr(), ret.as_mut_ptr().offset(12), 20);
|
ret.0[12..32].copy_from_slice(value);
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Convert string `s` to an `H256`. Will panic if `s` is not 64 characters long or if any of
|
/// Convert string `s` to an `H256`. Will panic if `s` is not 64 characters long or if any of
|
||||||
/// those characters are not 0-9, a-z or A-Z.
|
/// those characters are not 0-9, a-z or A-Z.
|
||||||
|
Loading…
Reference in New Issue
Block a user