binary for blockstatus, blockchaininfo

This commit is contained in:
Nikolay Volf 2016-05-06 17:16:03 +04:00
parent 96a4eb5b9e
commit 29531ae72f
7 changed files with 18 additions and 9 deletions

1
Cargo.lock generated
View File

@ -240,6 +240,7 @@ dependencies = [
"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",
"ethcore-devtools 1.2.0", "ethcore-devtools 1.2.0",
"ethcore-ipc 1.2.0",
"ethcore-ipc-codegen 1.2.0", "ethcore-ipc-codegen 1.2.0",
"ethcore-util 1.2.0", "ethcore-util 1.2.0",
"ethjson 0.1.0", "ethjson 0.1.0",

View File

@ -28,6 +28,7 @@ lazy_static = "0.1"
ethcore-devtools = { path = "../devtools" } ethcore-devtools = { path = "../devtools" }
ethjson = { path = "../json" } ethjson = { path = "../json" }
bloomchain = "0.1" bloomchain = "0.1"
"ethcore-ipc" = { path = "../ipc/rpc" }
[features] [features]
jit = ["evmjit"] jit = ["evmjit"]

View File

@ -85,6 +85,7 @@ extern crate num_cpus;
extern crate crossbeam; extern crate crossbeam;
extern crate ethjson; extern crate ethjson;
extern crate bloomchain; extern crate bloomchain;
extern crate ethcore_ipc as ipc;
#[cfg(test)] extern crate ethcore_devtools as devtools; #[cfg(test)] extern crate ethcore_devtools as devtools;
#[cfg(feature = "jit" )] extern crate evmjit; #[cfg(feature = "jit" )] extern crate evmjit;

View File

@ -16,8 +16,11 @@
//! Block status description module //! Block status description module
use ipc::binary::BinaryConvertError;
use std::collections::VecDeque;
/// General block status /// General block status
#[derive(Debug, Eq, PartialEq)] #[derive(Debug, Eq, PartialEq, Binary)]
pub enum BlockStatus { pub enum BlockStatus {
/// Part of the blockchain. /// Part of the blockchain.
InChain, InChain,

View File

@ -14,11 +14,14 @@
// 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/>.
use util::*; use util::numbers::*;
use header::BlockNumber; use header::BlockNumber;
use ipc::binary::BinaryConvertError;
use std::mem;
use std::collections::VecDeque;
/// Information about the blockchain gathered together. /// Information about the blockchain gathered together.
#[derive(Debug)] #[derive(Debug, Binary)]
pub struct BlockChainInfo { pub struct BlockChainInfo {
/// Blockchain difficulty. /// Blockchain difficulty.
pub total_difficulty: U256, pub total_difficulty: U256,

View File

@ -517,7 +517,7 @@ pub trait Uint: Sized + Default + FromStr + From<u64> + fmt::Debug + fmt::Displa
/// Return single byte /// Return single byte
fn byte(&self, index: usize) -> u8; fn byte(&self, index: usize) -> u8;
/// Get this Uint as slice of bytes /// 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)` /// Create `Uint(10**n)`
fn exp10(n: usize) -> Self; fn exp10(n: usize) -> Self;
@ -621,7 +621,7 @@ macro_rules! construct_uint {
(arr[index / 8] >> (((index % 8)) * 8)) as u8 (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()); assert!($n_words * 8 == bytes.len());
let &$name(ref arr) = self; let &$name(ref arr) = self;
for i in 0..bytes.len() { for i in 0..bytes.len() {
@ -780,7 +780,7 @@ macro_rules! construct_uint {
where S: serde::Serializer { where S: serde::Serializer {
let mut hex = "0x".to_owned(); let mut hex = "0x".to_owned();
let mut bytes = [0u8; 8 * $n_words]; 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); let len = cmp::max((self.bits() + 7) / 8, 1);
hex.push_str(bytes[bytes.len() - len..].to_hex().as_ref()); hex.push_str(bytes[bytes.len() - len..].to_hex().as_ref());
serializer.serialize_str(hex.as_ref()) serializer.serialize_str(hex.as_ref())
@ -1482,7 +1482,7 @@ mod tests {
let hex = "8090a0b0c0d0e0f00910203040506077583a2cf8264910e1436bda32571012f0"; let hex = "8090a0b0c0d0e0f00910203040506077583a2cf8264910e1436bda32571012f0";
let uint = U256::from_str(hex).unwrap(); let uint = U256::from_str(hex).unwrap();
let mut bytes = [0u8; 32]; let mut bytes = [0u8; 32];
uint.to_bytes(&mut bytes); uint.to_raw_bytes(&mut bytes);
let uint2 = U256::from(&bytes[..]); let uint2 = U256::from(&bytes[..]);
assert_eq!(uint, uint2); assert_eq!(uint, uint2);
} }

View File

@ -517,7 +517,7 @@ impl From<U256> for H256 {
fn from(value: U256) -> H256 { fn from(value: U256) -> H256 {
unsafe { unsafe {
let mut ret: H256 = ::std::mem::uninitialized(); let mut ret: H256 = ::std::mem::uninitialized();
value.to_bytes(&mut ret); value.to_raw_bytes(&mut ret);
ret ret
} }
} }
@ -527,7 +527,7 @@ impl<'_> From<&'_ U256> for H256 {
fn from(value: &'_ U256) -> H256 { fn from(value: &'_ U256) -> H256 {
unsafe { unsafe {
let mut ret: H256 = ::std::mem::uninitialized(); let mut ret: H256 = ::std::mem::uninitialized();
value.to_bytes(&mut ret); value.to_raw_bytes(&mut ret);
ret ret
} }
} }