1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
use std::io; use ser::{ Serializable, Stream, CompactInteger, Deserializable, Reader, Error as ReaderError }; use chain::Transaction; #[derive(Debug, PartialEq)] pub struct PrefilledTransaction { pub index: usize, pub transaction: Transaction, } impl Serializable for PrefilledTransaction { fn serialize(&self, stream: &mut Stream) { stream .append(&CompactInteger::from(self.index)) .append(&self.transaction); } } impl Deserializable for PrefilledTransaction { fn deserialize<T>(reader: &mut Reader<T>) -> Result<Self, ReaderError> where T: io::Read { let compact: CompactInteger = try!(reader.read()); let tx = PrefilledTransaction { index: compact.into(), transaction: try!(reader.read()), }; Ok(tx) } }