Bring integer arithmetic up to crates.io (#3943)

* split initial

* decouple crate

* fix tests compilation

* fix rlp tests
This commit is contained in:
Nikolay Volf 2016-12-23 19:53:06 +04:00 committed by Gav Wood
parent 0ed45eaf15
commit e7ca4445e2
12 changed files with 26 additions and 2334 deletions

14
Cargo.lock generated
View File

@ -108,6 +108,17 @@ dependencies = [
"syntex_syntax 0.42.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bigint"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bit-set"
version = "0.4.0"
@ -377,10 +388,10 @@ dependencies = [
name = "ethcore-bigint"
version = "0.1.2"
dependencies = [
"bigint 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -2350,6 +2361,7 @@ dependencies = [
"checksum arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "16e3bdb2f54b3ace0285975d59a97cf8ed3855294b2b6bc651fcf22a9c352975"
"checksum aster 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07d344974f0a155f091948aa389fb1b912d3a58414fbdb9c8d446d193ee3496a"
"checksum aster 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4df293303e8a52e1df7984ac1415e195f5fcbf51e4bb7bda54557861a3954a08"
"checksum bigint 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2311bcd71b281e142a095311c22509f0d6bcd87b3000d7dbaa810929b9d6f6ae"
"checksum bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9bf6104718e80d7b26a68fdbacff3481cfc05df670821affc7e9cbc1884400c"
"checksum bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5b97c2c8e8bbb4251754f559df8af22fb264853c7d009084a576cdf12565089d"
"checksum bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3"

View File

@ -6,12 +6,9 @@ license = "GPL-3.0"
name = "ethcore-bigint"
version = "0.1.2"
authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs"
[build-dependencies]
rustc_version = "0.1"
[dependencies]
bigint = "1.0"
rustc-serialize = "0.3"
heapsize = "0.3"
rand = "0.3.12"

View File

@ -1,25 +0,0 @@
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
extern crate rustc_version;
use rustc_version::{version_meta, Channel};
fn main() {
if let Channel::Nightly = version_meta().channel {
println!("cargo:rustc-cfg=asm_available");
}
}

View File

@ -25,7 +25,7 @@ use std::str::FromStr;
use rand::Rng;
use rand::os::OsRng;
use rustc_serialize::hex::{FromHex, FromHexError};
use uint::{Uint, U256};
use bigint::{Uint, U256};
/// Trait for a fixed-size byte array to be used as the output of hash functions.
pub trait FixedHash: Sized {
@ -512,7 +512,7 @@ pub type H256FastSet = HashSet<H256, BuildHasherDefault<PlainHasher>>;
#[cfg(test)]
mod tests {
use hash::*;
use uint::*;
use bigint::*;
use std::str::FromStr;
#[test]

View File

@ -20,9 +20,9 @@
extern crate rand;
extern crate rustc_serialize;
extern crate bigint;
#[macro_use] extern crate heapsize;
pub mod uint;
pub mod hash;
/// A prelude module for re-exporting all the types defined in this crate.
@ -34,6 +34,6 @@ pub mod hash;
/// let y = x + 1.into();
/// ```
pub mod prelude {
pub use ::uint::*;
pub use ::bigint::*;
pub use ::hash::*;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -21,8 +21,7 @@ use std::mem;
use std::fmt;
use std::cmp::Ordering;
use std::error::Error as StdError;
use bigint::uint::{Uint, U128, U256};
use bigint::hash::{H64, H128, H160, H256, H512, H520, H2048};
use bigint::prelude::{Uint, U128, U256, H64, H128, H160, H256, H512, H520, H2048};
use elastic_array::*;
/// Vector like object

View File

@ -163,7 +163,7 @@ impl<'a, 'view> Iterator for RlpIterator<'a, 'view> {
#[test]
fn break_it() {
use rustc_serialize::hex::FromHex;
use bigint::uint::U256;
use bigint::prelude::U256;
let h: Vec<u8> = FromHex::from_hex("f84d0589010efbef67941f79b2a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a0c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470").unwrap();
let r: Rlp = Rlp::new(&h);

View File

@ -17,7 +17,7 @@
use std::{fmt, cmp};
use std::str::FromStr;
use ::{Encodable, RlpDecodable, UntrustedRlp, RlpStream, View, Stream, DecoderError};
use bigint::uint::U256;
use bigint::prelude::U256;
#[test]
fn rlp_at() {

View File

@ -22,8 +22,7 @@ pub use error::*;
pub use bytes::*;
pub use vector::*;
pub use sha3::*;
pub use bigint::hash::*;
pub use bigint::uint::*;
pub use bigint::prelude::*;
pub use bigint::hash;
#[macro_export]

View File

@ -17,7 +17,7 @@
//! Coversion from json.
use standard::*;
use bigint::uint::*;
use bigint::prelude::*;
#[macro_export]
macro_rules! xjson {

View File

@ -16,7 +16,7 @@
//! Statistical functions.
use bigint::uint::*;
use bigint::prelude::*;
/// Discretised histogram.
#[derive(Debug, PartialEq)]
@ -62,7 +62,7 @@ impl Histogram {
#[cfg(test)]
mod tests {
use bigint::uint::U256;
use bigint::prelude::U256;
use super::Histogram;
#[test]