Get library building on stable

This commit is contained in:
Andrew Poelstra 2015-09-20 12:22:39 -05:00
parent 2320f099c1
commit 99a4845719
6 changed files with 560 additions and 551 deletions

View File

@ -1,4 +1,8 @@
language: rust
rust:
- stable
- beta
- nightly
install:
- git clone https://github.com/bitcoin/secp256k1.git

File diff suppressed because it is too large Load Diff

View File

@ -28,13 +28,7 @@
#![crate_type = "rlib"]
// Experimental features we need
#![feature(box_patterns)]
#![feature(concat_idents)]
#![feature(custom_derive, plugin)]
#![feature(hashmap_hasher)]
#![feature(ip_addr)]
#![feature(slice_patterns)]
#![cfg_attr(test, feature(test))]
#![cfg_attr(all(test, feature = "unstable"), feature(test))]
// Coding conventions
#![deny(non_upper_case_globals)]
@ -52,7 +46,7 @@ extern crate rand;
extern crate rustc_serialize as serialize;
extern crate secp256k1;
extern crate serde;
#[cfg(test)] extern crate test;
#[cfg(all(test, feature = "unstable"))] extern crate test;
extern crate time;
#[cfg(test)]

View File

@ -30,9 +30,7 @@
//!
use std::collections::HashMap;
use std::default::Default;
use std::hash::Hash;
use std::collections::hash_state::HashState;
use std::u32;
use util::hash::Sha256dHash;
@ -315,11 +313,10 @@ impl<D: SimpleDecoder, T: ConsensusDecodable<D>> ConsensusDecodable<D> for Box<T
}
// 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,
H: HashState + Default,
K: ConsensusEncodable<S> + Eq + Hash,
V: ConsensusEncodable<S>
K: ConsensusEncodable<S> + Eq + Hash,
V: ConsensusEncodable<S>
{
#[inline]
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,
H: HashState + Default,
K: ConsensusDecodable<D> + Eq + Hash,
V: ConsensusDecodable<D>
K: ConsensusDecodable<D> + Eq + Hash,
V: ConsensusDecodable<D>
{
#[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 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 {
ret.insert(try!(ConsensusDecodable::consensus_decode(d)),
try!(ConsensusDecodable::consensus_decode(d)));

View File

@ -33,10 +33,10 @@ use network::serialize::{RawEncoder, RawDecoder};
use util::{self, propagate_err};
/// Format an IP address in the 16-byte bitcoin protocol serialization
fn ipaddr_to_bitcoin_addr(ipaddr: &net::IpAddr) -> [u16; 8] {
match *ipaddr {
net::IpAddr::V4(ref addr) => addr.to_ipv6_mapped().segments(),
net::IpAddr::V6(ref addr) => addr.segments()
fn ipaddr_to_bitcoin_addr(addr: &net::SocketAddr) -> [u16; 8] {
match *addr {
net::SocketAddr::V4(ref addr) => addr.ip().to_ipv6_mapped().segments(),
net::SocketAddr::V6(ref addr) => addr.ip().segments()
}
}
@ -117,7 +117,7 @@ impl Socket {
Ok(addr) => {
Ok(Address {
services: self.services,
address: ipaddr_to_bitcoin_addr(&addr.ip()),
address: ipaddr_to_bitcoin_addr(&addr),
port: addr.port()
})
},
@ -133,7 +133,7 @@ impl Socket {
Ok(addr) => {
Ok(Address {
services: self.services,
address: ipaddr_to_bitcoin_addr(&addr.ip()),
address: ipaddr_to_bitcoin_addr(&addr),
port: addr.port()
})
},

View File

@ -249,8 +249,9 @@ impl<K, V> PatriciaTree<K, V>
}
match (tree.child_l.take(), tree.child_r.take()) {
(Some(_), Some(_)) => unreachable!(),
(Some(box PatriciaTree { data, child_l, child_r, skip_prefix, skip_len }), None) |
(None, Some(box PatriciaTree { data, child_l, child_r, skip_prefix, skip_len })) => {
(Some(child), None) | (None, Some(child)) => {
let child = *child; /* workaround for rustc #28536 */
let PatriciaTree { data, child_l, child_r, skip_len, skip_prefix } = child;
tree.data = data;
tree.child_l = child_l;
tree.child_r = child_r;
@ -307,8 +308,9 @@ impl<K, V> PatriciaTree<K, V>
return (false, ret);
}
// One child? Consolidate
(bit, Some(box PatriciaTree { data, child_l, child_r, skip_prefix, skip_len }), None) |
(bit, None, Some(box PatriciaTree { data, child_l, child_r, skip_prefix, skip_len })) => {
(bit, Some(child), None) | (bit, None, Some(child)) => {
let child = *child; /* workaround for rustc #28536 */
let PatriciaTree { data, child_l, child_r, skip_len, skip_prefix } = child;
tree.data = data;
tree.child_l = child_l;
tree.child_r = child_r;