Fixing clippy warnings. Implementing PartialEq for Uints
This commit is contained in:
parent
c2952b49b4
commit
07e704c968
@ -171,7 +171,7 @@ pub struct SealedBlock {
|
|||||||
|
|
||||||
impl<'x, 'y> OpenBlock<'x, 'y> {
|
impl<'x, 'y> OpenBlock<'x, 'y> {
|
||||||
/// Create a new OpenBlock ready for transaction pushing.
|
/// Create a new OpenBlock ready for transaction pushing.
|
||||||
pub fn new<'a, 'b>(engine: &'a Engine, db: JournalDB, parent: &Header, last_hashes: &'b LastHashes, author: Address, extra_data: Bytes) -> OpenBlock<'a, 'b> {
|
pub fn new(engine: &'x Engine, db: JournalDB, parent: &Header, last_hashes: &'y LastHashes, author: Address, extra_data: Bytes) -> Self {
|
||||||
let mut r = OpenBlock {
|
let mut r = OpenBlock {
|
||||||
block: ExecutedBlock::new(State::from_existing(db, parent.state_root().clone(), engine.account_start_nonce())),
|
block: ExecutedBlock::new(State::from_existing(db, parent.state_root().clone(), engine.account_start_nonce())),
|
||||||
engine: engine,
|
engine: engine,
|
||||||
@ -284,7 +284,7 @@ impl<'x, 'y> IsBlock for ClosedBlock<'x, 'y> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'x, 'y> ClosedBlock<'x, 'y> {
|
impl<'x, 'y> ClosedBlock<'x, 'y> {
|
||||||
fn new<'a, 'b>(open_block: OpenBlock<'a, 'b>, uncle_bytes: Bytes) -> ClosedBlock<'a, 'b> {
|
fn new(open_block: OpenBlock<'x, 'y>, uncle_bytes: Bytes) -> Self {
|
||||||
ClosedBlock {
|
ClosedBlock {
|
||||||
open_block: open_block,
|
open_block: open_block,
|
||||||
uncle_bytes: uncle_bytes,
|
uncle_bytes: uncle_bytes,
|
||||||
|
@ -87,13 +87,10 @@ impl Engine for Ethash {
|
|||||||
|
|
||||||
fn schedule(&self, env_info: &EnvInfo) -> Schedule {
|
fn schedule(&self, env_info: &EnvInfo) -> Schedule {
|
||||||
trace!(target: "client", "Creating schedule. param={:?}, fCML={}", self.spec().engine_params.get("frontierCompatibilityModeLimit"), self.u64_param("frontierCompatibilityModeLimit"));
|
trace!(target: "client", "Creating schedule. param={:?}, fCML={}", self.spec().engine_params.get("frontierCompatibilityModeLimit"), self.u64_param("frontierCompatibilityModeLimit"));
|
||||||
match env_info.number < self.u64_param("frontierCompatibilityModeLimit") {
|
if env_info.number < self.u64_param("frontierCompatibilityModeLimit") {
|
||||||
true => {
|
|
||||||
Schedule::new_frontier()
|
Schedule::new_frontier()
|
||||||
},
|
} else {
|
||||||
_ => {
|
|
||||||
Schedule::new_homestead()
|
Schedule::new_homestead()
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,9 +581,10 @@ impl Interpreter {
|
|||||||
let code_address = stack.pop_back();
|
let code_address = stack.pop_back();
|
||||||
let code_address = u256_to_address(&code_address);
|
let code_address = u256_to_address(&code_address);
|
||||||
|
|
||||||
let value = match instruction == instructions::DELEGATECALL {
|
let value = if instruction == instructions::DELEGATECALL {
|
||||||
true => None,
|
None
|
||||||
false => Some(stack.pop_back())
|
} else {
|
||||||
|
Some(stack.pop_back())
|
||||||
};
|
};
|
||||||
|
|
||||||
let in_off = stack.pop_back();
|
let in_off = stack.pop_back();
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
// TODO [todr] not really sure
|
// TODO [todr] not really sure
|
||||||
#![cfg_attr(feature="dev", allow(needless_range_loop))]
|
#![cfg_attr(feature="dev", allow(needless_range_loop))]
|
||||||
// Shorter than if-else
|
// Shorter than if-else
|
||||||
#![cfg_attr(feautre="dev", allow(match_bool))]
|
#![cfg_attr(feature="dev", allow(match_bool))]
|
||||||
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
|
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
|
||||||
#![cfg_attr(feature="dev", allow(clone_on_copy))]
|
#![cfg_attr(feature="dev", allow(clone_on_copy))]
|
||||||
|
|
||||||
|
@ -37,9 +37,10 @@ impl Default for Action {
|
|||||||
impl Decodable for Action {
|
impl Decodable for Action {
|
||||||
fn decode<D>(decoder: &D) -> Result<Self, DecoderError> where D: Decoder {
|
fn decode<D>(decoder: &D) -> Result<Self, DecoderError> where D: Decoder {
|
||||||
let rlp = decoder.as_rlp();
|
let rlp = decoder.as_rlp();
|
||||||
match rlp.is_empty() {
|
if rlp.is_empty() {
|
||||||
true => Ok(Action::Create),
|
Ok(Action::Create)
|
||||||
false => Ok(Action::Call(try!(rlp.as_val())))
|
} else {
|
||||||
|
Ok(Action::Call(try!(rlp.as_val())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,6 +80,7 @@ impl Transaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FromJson for SignedTransaction {
|
impl FromJson for SignedTransaction {
|
||||||
|
#[cfg_attr(feature="dev", allow(single_char_pattern))]
|
||||||
fn from_json(json: &Json) -> SignedTransaction {
|
fn from_json(json: &Json) -> SignedTransaction {
|
||||||
let t = Transaction {
|
let t = Transaction {
|
||||||
nonce: xjson!(&json["nonce"]),
|
nonce: xjson!(&json["nonce"]),
|
||||||
|
2
hook.sh
2
hook.sh
@ -1,3 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
echo "#!/bin/sh\ncargo test -p ethcore" >> ./.git/hooks/pre-push
|
echo "#!/bin/sh\ncargo test -p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity --features dev" > ./.git/hooks/pre-push
|
||||||
chmod +x ./.git/hooks/pre-push
|
chmod +x ./.git/hooks/pre-push
|
||||||
|
@ -194,9 +194,10 @@ impl Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn normalize_enode(e: &str) -> Option<String> {
|
fn normalize_enode(e: &str) -> Option<String> {
|
||||||
match is_valid_node_url(e) {
|
if is_valid_node_url(e) {
|
||||||
true => Some(e.to_owned()),
|
Some(e.to_owned())
|
||||||
false => None,
|
} else {
|
||||||
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +210,7 @@ impl Configuration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature="dev", allow(useless_format))]
|
||||||
fn net_addresses(&self) -> (Option<SocketAddr>, Option<SocketAddr>) {
|
fn net_addresses(&self) -> (Option<SocketAddr>, Option<SocketAddr>) {
|
||||||
let mut listen_address = None;
|
let mut listen_address = None;
|
||||||
let mut public_address = None;
|
let mut public_address = None;
|
||||||
|
@ -305,7 +305,7 @@ fn uuid_to_string(uuid: &Uuid) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn uuid_from_string(s: &str) -> Result<Uuid, UtilError> {
|
fn uuid_from_string(s: &str) -> Result<Uuid, UtilError> {
|
||||||
let parts: Vec<&str> = s.split("-").collect();
|
let parts: Vec<&str> = s.split('-').collect();
|
||||||
if parts.len() != 5 { return Err(UtilError::BadSize); }
|
if parts.len() != 5 { return Err(UtilError::BadSize); }
|
||||||
|
|
||||||
let mut uuid = H128::zero();
|
let mut uuid = H128::zero();
|
||||||
|
@ -69,13 +69,13 @@ impl<'a> Iterator for NibbleSliceIterator<'a> {
|
|||||||
|
|
||||||
impl<'a, 'view> NibbleSlice<'a> where 'a: 'view {
|
impl<'a, 'view> NibbleSlice<'a> where 'a: 'view {
|
||||||
/// Create a new nibble slice with the given byte-slice.
|
/// Create a new nibble slice with the given byte-slice.
|
||||||
pub fn new(data: &[u8]) -> NibbleSlice { NibbleSlice::new_offset(data, 0) }
|
pub fn new(data: &'a [u8]) -> Self { NibbleSlice::new_offset(data, 0) }
|
||||||
|
|
||||||
/// Create a new nibble slice with the given byte-slice with a nibble offset.
|
/// Create a new nibble slice with the given byte-slice with a nibble offset.
|
||||||
pub fn new_offset(data: &'a [u8], offset: usize) -> NibbleSlice { NibbleSlice{data: data, offset: offset, data_encode_suffix: &b""[..], offset_encode_suffix: 0} }
|
pub fn new_offset(data: &'a [u8], offset: usize) -> Self { NibbleSlice{data: data, offset: offset, data_encode_suffix: &b""[..], offset_encode_suffix: 0} }
|
||||||
|
|
||||||
/// Create a composed nibble slice; one followed by the other.
|
/// Create a composed nibble slice; one followed by the other.
|
||||||
pub fn new_composed(a: &'a NibbleSlice, b: &'a NibbleSlice) -> NibbleSlice<'a> { NibbleSlice{data: a.data, offset: a.offset, data_encode_suffix: b.data, offset_encode_suffix: b.offset} }
|
pub fn new_composed(a: &'a NibbleSlice, b: &'a NibbleSlice) -> Self { NibbleSlice{data: a.data, offset: a.offset, data_encode_suffix: b.data, offset_encode_suffix: b.offset} }
|
||||||
|
|
||||||
/*pub fn new_composed_bytes_offset(a: &NibbleSlice, b: &NibbleSlice) -> (Bytes, usize) {
|
/*pub fn new_composed_bytes_offset(a: &NibbleSlice, b: &NibbleSlice) -> (Bytes, usize) {
|
||||||
let r: Vec<u8>::with_capacity((a.len() + b.len() + 1) / 2);
|
let r: Vec<u8>::with_capacity((a.len() + b.len() + 1) / 2);
|
||||||
|
@ -141,7 +141,7 @@ pub trait Uint: Sized + Default + FromStr + From<u64> + FromJson + fmt::Debug +
|
|||||||
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
|
||||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
#[derive(Copy, Clone, Eq)]
|
||||||
pub struct $name(pub [u64; $n_words]);
|
pub struct $name(pub [u64; $n_words]);
|
||||||
|
|
||||||
impl Uint for $name {
|
impl Uint for $name {
|
||||||
@ -791,6 +791,17 @@ macro_rules! construct_uint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq for $name {
|
||||||
|
fn eq(&self, other: &$name) -> bool {
|
||||||
|
let &$name(ref me) = self;
|
||||||
|
let &$name(ref you) = other;
|
||||||
|
for i in 0..$n_words {
|
||||||
|
if me[$n_words - 1 - i] != you[$n_words - 1 - i] { return false; }
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Hash for $name {
|
impl Hash for $name {
|
||||||
fn hash<H>(&self, state: &mut H) where H: Hasher {
|
fn hash<H>(&self, state: &mut H) where H: Hasher {
|
||||||
unsafe { state.write(::std::slice::from_raw_parts(self.0.as_ptr() as *mut u8, self.0.len() * 8)); }
|
unsafe { state.write(::std::slice::from_raw_parts(self.0.as_ptr() as *mut u8, self.0.len() * 8)); }
|
||||||
|
Loading…
Reference in New Issue
Block a user