Get library building on stable
This commit is contained in:
parent
2320f099c1
commit
99a4845719
|
@ -1,4 +1,8 @@
|
||||||
language: rust
|
language: rust
|
||||||
|
rust:
|
||||||
|
- stable
|
||||||
|
- beta
|
||||||
|
- nightly
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- git clone https://github.com/bitcoin/secp256k1.git
|
- git clone https://github.com/bitcoin/secp256k1.git
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
10
src/lib.rs
10
src/lib.rs
|
@ -28,13 +28,7 @@
|
||||||
#![crate_type = "rlib"]
|
#![crate_type = "rlib"]
|
||||||
|
|
||||||
// Experimental features we need
|
// Experimental features we need
|
||||||
#![feature(box_patterns)]
|
#![cfg_attr(all(test, feature = "unstable"), feature(test))]
|
||||||
#![feature(concat_idents)]
|
|
||||||
#![feature(custom_derive, plugin)]
|
|
||||||
#![feature(hashmap_hasher)]
|
|
||||||
#![feature(ip_addr)]
|
|
||||||
#![feature(slice_patterns)]
|
|
||||||
#![cfg_attr(test, feature(test))]
|
|
||||||
|
|
||||||
// Coding conventions
|
// Coding conventions
|
||||||
#![deny(non_upper_case_globals)]
|
#![deny(non_upper_case_globals)]
|
||||||
|
@ -52,7 +46,7 @@ extern crate rand;
|
||||||
extern crate rustc_serialize as serialize;
|
extern crate rustc_serialize as serialize;
|
||||||
extern crate secp256k1;
|
extern crate secp256k1;
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
#[cfg(test)] extern crate test;
|
#[cfg(all(test, feature = "unstable"))] extern crate test;
|
||||||
extern crate time;
|
extern crate time;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -30,9 +30,7 @@
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::default::Default;
|
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::collections::hash_state::HashState;
|
|
||||||
use std::u32;
|
use std::u32;
|
||||||
|
|
||||||
use util::hash::Sha256dHash;
|
use util::hash::Sha256dHash;
|
||||||
|
@ -315,11 +313,10 @@ impl<D: SimpleDecoder, T: ConsensusDecodable<D>> ConsensusDecodable<D> for Box<T
|
||||||
}
|
}
|
||||||
|
|
||||||
// HashMap
|
// HashMap
|
||||||
impl<S, K, V, H> ConsensusEncodable<S> for HashMap<K, V, H>
|
impl<S, K, V> ConsensusEncodable<S> for HashMap<K, V>
|
||||||
where S: SimpleEncoder,
|
where S: SimpleEncoder,
|
||||||
H: HashState + Default,
|
K: ConsensusEncodable<S> + Eq + Hash,
|
||||||
K: ConsensusEncodable<S> + Eq + Hash,
|
V: ConsensusEncodable<S>
|
||||||
V: ConsensusEncodable<S>
|
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn consensus_encode(&self, s: &mut S) -> Result<(), S::Error> {
|
fn consensus_encode(&self, s: &mut S) -> Result<(), S::Error> {
|
||||||
|
@ -332,17 +329,16 @@ impl<S, K, V, H> ConsensusEncodable<S> for HashMap<K, V, H>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D, K, V, H> ConsensusDecodable<D> for HashMap<K, V, H>
|
impl<D, K, V> ConsensusDecodable<D> for HashMap<K, V>
|
||||||
where D: SimpleDecoder,
|
where D: SimpleDecoder,
|
||||||
H: HashState + Default,
|
K: ConsensusDecodable<D> + Eq + Hash,
|
||||||
K: ConsensusDecodable<D> + Eq + Hash,
|
V: ConsensusDecodable<D>
|
||||||
V: ConsensusDecodable<D>
|
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn consensus_decode(d: &mut D) -> Result<HashMap<K, V, H>, D::Error> {
|
fn consensus_decode(d: &mut D) -> Result<HashMap<K, V>, D::Error> {
|
||||||
let VarInt(len): VarInt = try!(ConsensusDecodable::consensus_decode(d));
|
let VarInt(len): VarInt = try!(ConsensusDecodable::consensus_decode(d));
|
||||||
|
|
||||||
let mut ret = HashMap::with_capacity_and_hash_state(len as usize, Default::default());
|
let mut ret = HashMap::with_capacity(len as usize);
|
||||||
for _ in 0..len {
|
for _ in 0..len {
|
||||||
ret.insert(try!(ConsensusDecodable::consensus_decode(d)),
|
ret.insert(try!(ConsensusDecodable::consensus_decode(d)),
|
||||||
try!(ConsensusDecodable::consensus_decode(d)));
|
try!(ConsensusDecodable::consensus_decode(d)));
|
||||||
|
|
|
@ -33,10 +33,10 @@ use network::serialize::{RawEncoder, RawDecoder};
|
||||||
use util::{self, propagate_err};
|
use util::{self, propagate_err};
|
||||||
|
|
||||||
/// Format an IP address in the 16-byte bitcoin protocol serialization
|
/// Format an IP address in the 16-byte bitcoin protocol serialization
|
||||||
fn ipaddr_to_bitcoin_addr(ipaddr: &net::IpAddr) -> [u16; 8] {
|
fn ipaddr_to_bitcoin_addr(addr: &net::SocketAddr) -> [u16; 8] {
|
||||||
match *ipaddr {
|
match *addr {
|
||||||
net::IpAddr::V4(ref addr) => addr.to_ipv6_mapped().segments(),
|
net::SocketAddr::V4(ref addr) => addr.ip().to_ipv6_mapped().segments(),
|
||||||
net::IpAddr::V6(ref addr) => addr.segments()
|
net::SocketAddr::V6(ref addr) => addr.ip().segments()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ impl Socket {
|
||||||
Ok(addr) => {
|
Ok(addr) => {
|
||||||
Ok(Address {
|
Ok(Address {
|
||||||
services: self.services,
|
services: self.services,
|
||||||
address: ipaddr_to_bitcoin_addr(&addr.ip()),
|
address: ipaddr_to_bitcoin_addr(&addr),
|
||||||
port: addr.port()
|
port: addr.port()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -133,7 +133,7 @@ impl Socket {
|
||||||
Ok(addr) => {
|
Ok(addr) => {
|
||||||
Ok(Address {
|
Ok(Address {
|
||||||
services: self.services,
|
services: self.services,
|
||||||
address: ipaddr_to_bitcoin_addr(&addr.ip()),
|
address: ipaddr_to_bitcoin_addr(&addr),
|
||||||
port: addr.port()
|
port: addr.port()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -249,8 +249,9 @@ impl<K, V> PatriciaTree<K, V>
|
||||||
}
|
}
|
||||||
match (tree.child_l.take(), tree.child_r.take()) {
|
match (tree.child_l.take(), tree.child_r.take()) {
|
||||||
(Some(_), Some(_)) => unreachable!(),
|
(Some(_), Some(_)) => unreachable!(),
|
||||||
(Some(box PatriciaTree { data, child_l, child_r, skip_prefix, skip_len }), None) |
|
(Some(child), None) | (None, Some(child)) => {
|
||||||
(None, Some(box PatriciaTree { data, child_l, child_r, skip_prefix, skip_len })) => {
|
let child = *child; /* workaround for rustc #28536 */
|
||||||
|
let PatriciaTree { data, child_l, child_r, skip_len, skip_prefix } = child;
|
||||||
tree.data = data;
|
tree.data = data;
|
||||||
tree.child_l = child_l;
|
tree.child_l = child_l;
|
||||||
tree.child_r = child_r;
|
tree.child_r = child_r;
|
||||||
|
@ -307,8 +308,9 @@ impl<K, V> PatriciaTree<K, V>
|
||||||
return (false, ret);
|
return (false, ret);
|
||||||
}
|
}
|
||||||
// One child? Consolidate
|
// One child? Consolidate
|
||||||
(bit, Some(box PatriciaTree { data, child_l, child_r, skip_prefix, skip_len }), None) |
|
(bit, Some(child), None) | (bit, None, Some(child)) => {
|
||||||
(bit, None, Some(box PatriciaTree { data, child_l, child_r, skip_prefix, skip_len })) => {
|
let child = *child; /* workaround for rustc #28536 */
|
||||||
|
let PatriciaTree { data, child_l, child_r, skip_len, skip_prefix } = child;
|
||||||
tree.data = data;
|
tree.data = data;
|
||||||
tree.child_l = child_l;
|
tree.child_l = child_l;
|
||||||
tree.child_r = child_r;
|
tree.child_r = child_r;
|
||||||
|
|
Loading…
Reference in New Issue