binary for blockstatus, blockchaininfo
This commit is contained in:
parent
96a4eb5b9e
commit
29531ae72f
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -240,6 +240,7 @@ dependencies = [
|
||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethash 1.2.0",
|
||||
"ethcore-devtools 1.2.0",
|
||||
"ethcore-ipc 1.2.0",
|
||||
"ethcore-ipc-codegen 1.2.0",
|
||||
"ethcore-util 1.2.0",
|
||||
"ethjson 0.1.0",
|
||||
|
@ -28,6 +28,7 @@ lazy_static = "0.1"
|
||||
ethcore-devtools = { path = "../devtools" }
|
||||
ethjson = { path = "../json" }
|
||||
bloomchain = "0.1"
|
||||
"ethcore-ipc" = { path = "../ipc/rpc" }
|
||||
|
||||
[features]
|
||||
jit = ["evmjit"]
|
||||
|
@ -85,6 +85,7 @@ extern crate num_cpus;
|
||||
extern crate crossbeam;
|
||||
extern crate ethjson;
|
||||
extern crate bloomchain;
|
||||
extern crate ethcore_ipc as ipc;
|
||||
|
||||
#[cfg(test)] extern crate ethcore_devtools as devtools;
|
||||
#[cfg(feature = "jit" )] extern crate evmjit;
|
||||
|
@ -16,8 +16,11 @@
|
||||
|
||||
//! Block status description module
|
||||
|
||||
use ipc::binary::BinaryConvertError;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
/// General block status
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
#[derive(Debug, Eq, PartialEq, Binary)]
|
||||
pub enum BlockStatus {
|
||||
/// Part of the blockchain.
|
||||
InChain,
|
||||
|
@ -14,11 +14,14 @@
|
||||
// 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::*;
|
||||
use util::numbers::*;
|
||||
use header::BlockNumber;
|
||||
use ipc::binary::BinaryConvertError;
|
||||
use std::mem;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
/// Information about the blockchain gathered together.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Binary)]
|
||||
pub struct BlockChainInfo {
|
||||
/// Blockchain difficulty.
|
||||
pub total_difficulty: U256,
|
||||
|
@ -517,7 +517,7 @@ pub trait Uint: Sized + Default + FromStr + From<u64> + fmt::Debug + fmt::Displa
|
||||
/// Return single byte
|
||||
fn byte(&self, index: usize) -> u8;
|
||||
/// Get this Uint as slice of bytes
|
||||
fn to_bytes(&self, bytes: &mut[u8]);
|
||||
fn to_raw_bytes(&self, bytes: &mut[u8]);
|
||||
|
||||
/// Create `Uint(10**n)`
|
||||
fn exp10(n: usize) -> Self;
|
||||
@ -621,7 +621,7 @@ macro_rules! construct_uint {
|
||||
(arr[index / 8] >> (((index % 8)) * 8)) as u8
|
||||
}
|
||||
|
||||
fn to_bytes(&self, bytes: &mut[u8]) {
|
||||
fn to_raw_bytes(&self, bytes: &mut[u8]) {
|
||||
assert!($n_words * 8 == bytes.len());
|
||||
let &$name(ref arr) = self;
|
||||
for i in 0..bytes.len() {
|
||||
@ -780,7 +780,7 @@ macro_rules! construct_uint {
|
||||
where S: serde::Serializer {
|
||||
let mut hex = "0x".to_owned();
|
||||
let mut bytes = [0u8; 8 * $n_words];
|
||||
self.to_bytes(&mut bytes);
|
||||
self.to_raw_bytes(&mut bytes);
|
||||
let len = cmp::max((self.bits() + 7) / 8, 1);
|
||||
hex.push_str(bytes[bytes.len() - len..].to_hex().as_ref());
|
||||
serializer.serialize_str(hex.as_ref())
|
||||
@ -1482,7 +1482,7 @@ mod tests {
|
||||
let hex = "8090a0b0c0d0e0f00910203040506077583a2cf8264910e1436bda32571012f0";
|
||||
let uint = U256::from_str(hex).unwrap();
|
||||
let mut bytes = [0u8; 32];
|
||||
uint.to_bytes(&mut bytes);
|
||||
uint.to_raw_bytes(&mut bytes);
|
||||
let uint2 = U256::from(&bytes[..]);
|
||||
assert_eq!(uint, uint2);
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ impl From<U256> for H256 {
|
||||
fn from(value: U256) -> H256 {
|
||||
unsafe {
|
||||
let mut ret: H256 = ::std::mem::uninitialized();
|
||||
value.to_bytes(&mut ret);
|
||||
value.to_raw_bytes(&mut ret);
|
||||
ret
|
||||
}
|
||||
}
|
||||
@ -527,7 +527,7 @@ impl<'_> From<&'_ U256> for H256 {
|
||||
fn from(value: &'_ U256) -> H256 {
|
||||
unsafe {
|
||||
let mut ret: H256 = ::std::mem::uninitialized();
|
||||
value.to_bytes(&mut ret);
|
||||
value.to_raw_bytes(&mut ret);
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user