Fixes for recent stdlib changes
This commit is contained in:
parent
6d4861b472
commit
d9d7416e32
|
@ -129,7 +129,9 @@ impl SignatureHashType {
|
|||
/// A structure that can hold either a slice or vector, as necessary
|
||||
#[deriving(Clone, Show)]
|
||||
pub enum MaybeOwned<'a> {
|
||||
/// Freshly allocated memory
|
||||
Owned(Vec<u8>),
|
||||
/// Pointer into the original script
|
||||
Slice(&'a [u8])
|
||||
}
|
||||
|
||||
|
@ -140,7 +142,7 @@ impl<'a> PartialEq for MaybeOwned<'a> {
|
|||
|
||||
impl<'a> Eq for MaybeOwned<'a> {}
|
||||
|
||||
impl<'a> Vector<u8> for MaybeOwned<'a> {
|
||||
impl<'a> Slice<u8> for MaybeOwned<'a> {
|
||||
#[inline]
|
||||
fn as_slice<'a>(&'a self) -> &'a [u8] {
|
||||
match *self {
|
||||
|
|
|
@ -200,28 +200,22 @@ impl UtxoSet {
|
|||
// skip the genesis since we don't validate this script. (TODO this might
|
||||
// be a consensus bug since we don't even check that the opcodes make sense.)
|
||||
for tx in block.txdata.iter().skip(1) {
|
||||
let s = self as *mut _ as *const UtxoSet;
|
||||
let tx = tx as *const _;
|
||||
let s = self as *mut _ as *const UtxoSet;
|
||||
let tx = tx as *const _;
|
||||
future_vec.push(Future::spawn(proc() {
|
||||
let tx = unsafe {&*tx};
|
||||
let tx = unsafe {&*tx};
|
||||
for (n, input) in tx.input.iter().enumerate() {
|
||||
let txo = unsafe { (*s).get_utxo(input.prev_hash, input.prev_index) };
|
||||
match txo {
|
||||
Some(txo) => {
|
||||
let mut stack = Vec::with_capacity(6);
|
||||
match input.script_sig.evaluate(&mut stack, Some((tx, n))) {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
println!("txid was {}", tx.bitcoin_hash());
|
||||
return false;
|
||||
}
|
||||
if input.script_sig.evaluate(&mut stack, Some((tx, n))).is_err() {
|
||||
println!("txid was {}", tx.bitcoin_hash());
|
||||
return false;
|
||||
}
|
||||
match txo.script_pubkey.evaluate(&mut stack, Some((tx, n))) {
|
||||
Ok(_) => {},
|
||||
Err(e) => {
|
||||
println!("txid was {}", tx.bitcoin_hash());
|
||||
return false;
|
||||
}
|
||||
if txo.script_pubkey.evaluate(&mut stack, Some((tx, n))).is_err() {
|
||||
println!("txid was {}", tx.bitcoin_hash());
|
||||
return false;
|
||||
}
|
||||
match stack.pop() {
|
||||
Some(v) => {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
use std::io::{IoResult, standard_error, ConnectionFailed};
|
||||
use std::io::timer;
|
||||
use std::time::Duration;
|
||||
|
||||
use network::constants::Network;
|
||||
use network::message::{NetworkMessage, Verack};
|
||||
|
@ -78,7 +79,7 @@ pub trait Listener {
|
|||
}
|
||||
Err(e) => {
|
||||
println!("Received error {:} when decoding message. Pausing for 5 seconds then reconnecting.", e);
|
||||
timer::sleep(5000);
|
||||
timer::sleep(Duration::seconds(5));
|
||||
// Reconnect
|
||||
sock.reconnect()
|
||||
// Create version message
|
||||
|
|
|
@ -41,7 +41,7 @@ impl<S:SimpleEncoder<E>, E> ConsensusEncodable<S, E> for CommandString {
|
|||
fn consensus_encode(&self, s: &mut S) -> Result<(), E> {
|
||||
let &CommandString(ref inner_str) = self;
|
||||
let mut rawbytes = [0u8, ..12];
|
||||
rawbytes.copy_from(inner_str.as_bytes().as_slice());
|
||||
rawbytes.clone_from_slice(inner_str.as_bytes().as_slice());
|
||||
rawbytes.consensus_encode(s)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
//!
|
||||
|
||||
use alloc::heap::{allocate, reallocate, deallocate};
|
||||
use std::raw::Slice;
|
||||
use std::raw;
|
||||
use std::slice::{Items, MutItems};
|
||||
use std::{fmt, mem, ptr};
|
||||
use std::u32;
|
||||
|
@ -76,7 +76,7 @@ impl<T> ThinVec<T> {
|
|||
/// Get vector as mutable slice
|
||||
#[inline]
|
||||
pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
|
||||
unsafe { mem::transmute(Slice { data: self.ptr as *const T, len: self.cap as uint }) }
|
||||
unsafe { mem::transmute(raw::Slice { data: self.ptr as *const T, len: self.cap as uint }) }
|
||||
}
|
||||
|
||||
/// Accessor
|
||||
|
@ -166,16 +166,16 @@ impl<T:Clone> ThinVec<T> {
|
|||
for i in range(0, other.len()) {
|
||||
unsafe {
|
||||
ptr::write(self.as_mut_slice().unsafe_mut_ref(old_cap + i),
|
||||
other.unsafe_ref(i).clone());
|
||||
other.unsafe_get(i).clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Vector<T> for ThinVec<T> {
|
||||
impl<T> Slice<T> for ThinVec<T> {
|
||||
#[inline]
|
||||
fn as_slice<'a>(&'a self) -> &'a [T] {
|
||||
unsafe { mem::transmute(Slice { data: self.ptr as *const T, len: self.cap as uint }) }
|
||||
unsafe { mem::transmute(raw::Slice { data: self.ptr as *const T, len: self.cap as uint }) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ impl<T:Clone> Clone for ThinVec<T> {
|
|||
// if T is Copy
|
||||
for i in range(0, self.len()) {
|
||||
ptr::write(ret.as_mut_slice().unsafe_mut_ref(i),
|
||||
self.as_slice().unsafe_ref(i).clone());
|
||||
self.as_slice().unsafe_get(i).clone());
|
||||
}
|
||||
ret
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue