Adding rustfmt_skip and fixing couple of places that have troubles after formatting.

This commit is contained in:
Tomusdrw 2016-02-16 10:42:56 +01:00
parent 771bcb5bda
commit 22e2458ce5
5 changed files with 26 additions and 23 deletions

View File

@ -29,6 +29,7 @@
// Floor[(CacheSizeBytesInit + CacheGrowth * j) / HashBytes]}, // Floor[(CacheSizeBytesInit + CacheGrowth * j) / HashBytes]},
// While[! PrimeQ[i], i--]; // While[! PrimeQ[i], i--];
// Sow[i*HashBytes]; j++]]]][[2]][[1]] // Sow[i*HashBytes]; j++]]]][[2]][[1]]
#[cfg_attr(rustfmt, rustfmt_skip)]
pub const DAG_SIZES: [u64; 2048] = [ pub const DAG_SIZES: [u64; 2048] = [
1073739904u64, 1082130304u64, 1090514816u64, 1098906752u64, 1107293056u64, 1073739904u64, 1082130304u64, 1090514816u64, 1098906752u64, 1107293056u64,
1115684224u64, 1124070016u64, 1132461952u64, 1140849536u64, 1149232768u64, 1115684224u64, 1124070016u64, 1132461952u64, 1140849536u64, 1149232768u64,
@ -456,6 +457,7 @@ pub const DAG_SIZES: [u64; 2048] = [
// Module[{i = Floor[(DataSetSizeBytesInit + DataSetGrowth * j) / (CacheMultiplier * HashBytes)]}, // Module[{i = Floor[(DataSetSizeBytesInit + DataSetGrowth * j) / (CacheMultiplier * HashBytes)]},
// While[! PrimeQ[i], i--]; // While[! PrimeQ[i], i--];
// Sow[i*HashBytes]; j++]]]][[2]][[1]] // Sow[i*HashBytes]; j++]]]][[2]][[1]]
#[cfg_attr(rustfmt, rustfmt_skip)]
pub const CACHE_SIZES: [u64; 2048] = [ pub const CACHE_SIZES: [u64; 2048] = [
16776896u64, 16907456u64, 17039296u64, 17170112u64, 17301056u64, 17432512u64, 17563072u64, 16776896u64, 16907456u64, 17039296u64, 17170112u64, 17301056u64, 17432512u64, 17563072u64,
17693888u64, 17824192u64, 17955904u64, 18087488u64, 18218176u64, 18349504u64, 18481088u64, 17693888u64, 17824192u64, 17955904u64, 18087488u64, 18218176u64, 18349504u64, 18481088u64,

View File

@ -137,6 +137,7 @@ impl InstructionInfo {
} }
} }
#[cfg_attr(rustfmt, rustfmt_skip)]
/// Return details about specific instruction /// Return details about specific instruction
pub fn get_info (instruction: Instruction) -> InstructionInfo { pub fn get_info (instruction: Instruction) -> InstructionInfo {
match instruction { match instruction {
@ -301,7 +302,7 @@ pub const EXP: Instruction = 0x0a;
pub const SIGNEXTEND: Instruction = 0x0b; pub const SIGNEXTEND: Instruction = 0x0b;
/// less-than comparision /// less-than comparision
pub const LT: Instruction = 0x10; pub const LT: Instruction = 0x10;
/// greater-than comparision /// greater-than comparision
pub const GT: Instruction = 0x11; pub const GT: Instruction = 0x11;
/// signed less-than comparision /// signed less-than comparision
@ -324,10 +325,10 @@ pub const NOT: Instruction = 0x19;
pub const BYTE: Instruction = 0x1a; pub const BYTE: Instruction = 0x1a;
/// compute SHA3-256 hash /// compute SHA3-256 hash
pub const SHA3: Instruction = 0x20; pub const SHA3: Instruction = 0x20;
/// get address of currently executing account /// get address of currently executing account
pub const ADDRESS: Instruction = 0x30; pub const ADDRESS: Instruction = 0x30;
/// get balance of the given account /// get balance of the given account
pub const BALANCE: Instruction = 0x31; pub const BALANCE: Instruction = 0x31;
/// get execution origination address /// get execution origination address
@ -367,7 +368,7 @@ pub const DIFFICULTY: Instruction = 0x44;
pub const GASLIMIT: Instruction = 0x45; pub const GASLIMIT: Instruction = 0x45;
/// remove item from stack /// remove item from stack
pub const POP: Instruction = 0x50; pub const POP: Instruction = 0x50;
/// load word from memory /// load word from memory
pub const MLOAD: Instruction = 0x51; pub const MLOAD: Instruction = 0x51;
/// save word to memory /// save word to memory
@ -392,7 +393,7 @@ pub const GAS: Instruction = 0x5a;
pub const JUMPDEST: Instruction = 0x5b; pub const JUMPDEST: Instruction = 0x5b;
/// place 1 byte item on stack /// place 1 byte item on stack
pub const PUSH1: Instruction = 0x60; pub const PUSH1: Instruction = 0x60;
/// place 2 byte item on stack /// place 2 byte item on stack
pub const PUSH2: Instruction = 0x61; pub const PUSH2: Instruction = 0x61;
/// place 3 byte item on stack /// place 3 byte item on stack
@ -457,7 +458,7 @@ pub const PUSH31: Instruction = 0x7e;
pub const PUSH32: Instruction = 0x7f; pub const PUSH32: Instruction = 0x7f;
/// copies the highest item in the stack to the top of the stack /// copies the highest item in the stack to the top of the stack
pub const DUP1: Instruction = 0x80; pub const DUP1: Instruction = 0x80;
/// copies the second highest item in the stack to the top of the stack /// copies the second highest item in the stack to the top of the stack
pub const DUP2: Instruction = 0x81; pub const DUP2: Instruction = 0x81;
/// copies the third highest item in the stack to the top of the stack /// copies the third highest item in the stack to the top of the stack
@ -490,7 +491,7 @@ pub const DUP15: Instruction = 0x8e;
pub const DUP16: Instruction = 0x8f; pub const DUP16: Instruction = 0x8f;
/// swaps the highest and second highest value on the stack /// swaps the highest and second highest value on the stack
pub const SWAP1: Instruction = 0x90; pub const SWAP1: Instruction = 0x90;
/// swaps the highest and third highest value on the stack /// swaps the highest and third highest value on the stack
pub const SWAP2: Instruction = 0x91; pub const SWAP2: Instruction = 0x91;
/// swaps the highest and 4th highest value on the stack /// swaps the highest and 4th highest value on the stack
@ -523,7 +524,7 @@ pub const SWAP15: Instruction = 0x9e;
pub const SWAP16: Instruction = 0x9f; pub const SWAP16: Instruction = 0x9f;
/// Makes a log entry; no topics. /// Makes a log entry; no topics.
pub const LOG0: Instruction = 0xa0; pub const LOG0: Instruction = 0xa0;
/// Makes a log entry; 1 topic. /// Makes a log entry; 1 topic.
pub const LOG1: Instruction = 0xa1; pub const LOG1: Instruction = 0xa1;
/// Makes a log entry; 2 topics. /// Makes a log entry; 2 topics.
@ -536,7 +537,7 @@ pub const LOG4: Instruction = 0xa4;
pub const MAX_NO_OF_TOPICS : usize = 4; pub const MAX_NO_OF_TOPICS : usize = 4;
/// create a new account with associated code /// create a new account with associated code
pub const CREATE: Instruction = 0xf0; pub const CREATE: Instruction = 0xf0;
/// message-call into an account /// message-call into an account
pub const CALL: Instruction = 0xf1; pub const CALL: Instruction = 0xf1;
/// message-call with another account's code only /// message-call with another account's code only
@ -546,5 +547,5 @@ pub const RETURN: Instruction = 0xf3;
/// like CALLCODE but keeps caller's value and sender /// like CALLCODE but keeps caller's value and sender
pub const DELEGATECALL: Instruction = 0xf4; pub const DELEGATECALL: Instruction = 0xf4;
/// halt execution and register account for later deletion /// halt execution and register account for later deletion
pub const SUICIDE: Instruction = 0xff; pub const SUICIDE: Instruction = 0xff;

View File

@ -202,7 +202,7 @@ pub mod ec {
match context.verify(&try!(Message::from_slice(&message)), &sig, &publ) { match context.verify(&try!(Message::from_slice(&message)), &sig, &publ) {
Ok(_) => Ok(true), Ok(_) => Ok(true),
Err(Error::IncorrectSignature) => Ok(false), Err(Error::IncorrectSignature) => Ok(false),
Err(x) => Err(<CryptoError as From<Error>>::from(x)) Err(x) => Err(CryptoError::from(x))
} }
} }

View File

@ -24,7 +24,7 @@ impl<'a> From<UntrustedRlp<'a>> for Rlp<'a> {
} }
/// Data-oriented view onto trusted rlp-slice. /// Data-oriented view onto trusted rlp-slice.
/// ///
/// Unlikely to `UntrustedRlp` doesn't bother you with error /// Unlikely to `UntrustedRlp` doesn't bother you with error
/// handling. It assumes that you know what you are doing. /// handling. It assumes that you know what you are doing.
#[derive(Debug)] #[derive(Debug)]
@ -44,7 +44,7 @@ impl<'a, 'view> View<'a, 'view> for Rlp<'a> where 'a: 'view {
type Data = &'a [u8]; type Data = &'a [u8];
type Item = Rlp<'a>; type Item = Rlp<'a>;
type Iter = RlpIterator<'a, 'view>; type Iter = RlpIterator<'a, 'view>;
/// Create a new instance of `Rlp` /// Create a new instance of `Rlp`
fn new(bytes: &'a [u8]) -> Rlp<'a> { fn new(bytes: &'a [u8]) -> Rlp<'a> {
Rlp { Rlp {
@ -153,7 +153,7 @@ impl<'a, 'view> Iterator for RlpIterator<'a, 'view> {
fn next(&mut self) -> Option<Rlp<'a>> { fn next(&mut self) -> Option<Rlp<'a>> {
let index = self.index; let index = self.index;
let result = self.rlp.rlp.at(index).ok().map(| iter | { From::from(iter) }); let result = self.rlp.rlp.at(index).ok().map(From::from);
self.index += 1; self.index += 1;
result result
} }

View File

@ -31,7 +31,7 @@
// //
//! Big unsigned integer types //! Big unsigned integer types
//! //!
//! Implementation of a various large-but-fixed sized unsigned integer types. //! Implementation of a various large-but-fixed sized unsigned integer types.
//! The functions here are designed to be fast. //! The functions here are designed to be fast.
//! //!
@ -102,7 +102,7 @@ pub trait Uint: Sized + Default + FromStr + From<u64> + FromJson + fmt::Debug +
/// Conversion to u64 with overflow checking /// Conversion to u64 with overflow checking
fn as_u64(&self) -> u64; fn as_u64(&self) -> u64;
/// Return the least number of bits needed to represent the number /// Return the least number of bits needed to represent the number
fn bits(&self) -> usize; fn bits(&self) -> usize;
/// Return if specific bit is set /// Return if specific bit is set
@ -127,7 +127,7 @@ pub trait Uint: Sized + Default + FromStr + From<u64> + FromJson + fmt::Debug +
/// Multiple this `Uint` with other returning result and possible overflow /// Multiple this `Uint` with other returning result and possible overflow
fn overflowing_mul(self, other: Self) -> (Self, bool); fn overflowing_mul(self, other: Self) -> (Self, bool);
/// Divide this `Uint` by other returning result and possible overflow /// Divide this `Uint` by other returning result and possible overflow
fn overflowing_div(self, other: Self) -> (Self, bool); fn overflowing_div(self, other: Self) -> (Self, bool);
@ -136,7 +136,7 @@ pub trait Uint: Sized + Default + FromStr + From<u64> + FromJson + fmt::Debug +
/// Returns negation of this `Uint` and overflow (always true) /// Returns negation of this `Uint` and overflow (always true)
fn overflowing_neg(self) -> (Self, bool); fn overflowing_neg(self) -> (Self, bool);
/// Shifts this `Uint` and returns overflow /// Shifts this `Uint` and returns overflow
fn overflowing_shl(self, shift: u32) -> (Self, bool); fn overflowing_shl(self, shift: u32) -> (Self, bool);
} }
@ -180,7 +180,7 @@ macro_rules! construct_uint {
fn as_u32(&self) -> u32 { fn as_u32(&self) -> u32 {
let &$name(ref arr) = self; let &$name(ref arr) = self;
if (arr[0] & (0xffffffffu64 << 32)) != 0 { if (arr[0] & (0xffffffffu64 << 32)) != 0 {
panic!("Integer overflow when casting U256") panic!("Integer overflow when casting U256")
} }
self.as_u64() as u32 self.as_u64() as u32
} }
@ -191,7 +191,7 @@ macro_rules! construct_uint {
let &$name(ref arr) = self; let &$name(ref arr) = self;
for i in 1..$n_words { for i in 1..$n_words {
if arr[i] != 0 { if arr[i] != 0 {
panic!("Integer overflow when casting U256") panic!("Integer overflow when casting U256")
} }
} }
arr[0] arr[0]
@ -325,7 +325,7 @@ macro_rules! construct_uint {
if b_carry { if b_carry {
let ret = overflowing!($name(ret).overflowing_add($name(carry)), overflow); let ret = overflowing!($name(ret).overflowing_add($name(carry)), overflow);
(ret, overflow) (ret, overflow)
} else { } else {
($name(ret), overflow) ($name(ret), overflow)
} }
} }
@ -453,7 +453,7 @@ macro_rules! construct_uint {
} }
impl serde::Serialize for $name { impl serde::Serialize for $name {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error> fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
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];
@ -1129,7 +1129,7 @@ mod tests {
assert_eq!(U256::from(105u8) / U256::from(5u8), U256::from(21u8)); assert_eq!(U256::from(105u8) / U256::from(5u8), U256::from(21u8));
let div = mult / U256::from(300u16); let div = mult / U256::from(300u16);
assert_eq!(div, U256([0x9F30411021524112u64, 0x0001BD5B7DDFBD5A, 0, 0])); assert_eq!(div, U256([0x9F30411021524112u64, 0x0001BD5B7DDFBD5A, 0, 0]));
//// TODO: bit inversion // TODO: bit inversion
} }
#[test] #[test]