Remove version fields from Block, Tx messages.
These are included in the Block, Transaction objects themselves, so the previous code ended up trying to deserialize two version fields per object. Closes #226.
This commit is contained in:
parent
51c744b1ae
commit
eeb4a2470b
|
@ -203,13 +203,7 @@ impl Codec {
|
|||
}
|
||||
Addr(ref addrs) => addrs.zcash_serialize(&mut writer)?,
|
||||
GetAddr => { /* Empty payload -- no-op */ }
|
||||
Block {
|
||||
ref version,
|
||||
ref block,
|
||||
} => {
|
||||
writer.write_u32::<LittleEndian>(version.0)?;
|
||||
block.zcash_serialize(&mut writer)?
|
||||
}
|
||||
Block(ref block) => block.zcash_serialize(&mut writer)?,
|
||||
GetBlocks {
|
||||
ref version,
|
||||
ref block_locator_hashes,
|
||||
|
@ -232,13 +226,7 @@ impl Codec {
|
|||
Inv(ref hashes) => hashes.zcash_serialize(&mut writer)?,
|
||||
GetData(ref hashes) => hashes.zcash_serialize(&mut writer)?,
|
||||
NotFound(ref hashes) => hashes.zcash_serialize(&mut writer)?,
|
||||
Tx {
|
||||
ref version,
|
||||
ref transaction,
|
||||
} => {
|
||||
writer.write_u32::<LittleEndian>(version.0)?;
|
||||
transaction.zcash_serialize(&mut writer)?
|
||||
}
|
||||
Tx(ref transaction) => transaction.zcash_serialize(&mut writer)?,
|
||||
Mempool => { /* Empty payload -- no-op */ }
|
||||
FilterLoad {
|
||||
ref filter,
|
||||
|
@ -465,10 +453,7 @@ impl Codec {
|
|||
}
|
||||
|
||||
fn read_block<R: Read>(&self, mut reader: R) -> Result<Message, Error> {
|
||||
Ok(Message::Block {
|
||||
version: Version(reader.read_u32::<LittleEndian>()?),
|
||||
block: Box::new(Block::zcash_deserialize(&mut reader)?),
|
||||
})
|
||||
Ok(Message::Block(Box::new(Block::zcash_deserialize(reader)?)))
|
||||
}
|
||||
|
||||
fn read_getblocks<R: Read>(&self, mut reader: R) -> Result<Message, Error> {
|
||||
|
@ -508,11 +493,8 @@ impl Codec {
|
|||
Ok(Message::NotFound(Vec::zcash_deserialize(reader)?))
|
||||
}
|
||||
|
||||
fn read_tx<R: Read>(&self, mut reader: R) -> Result<Message, Error> {
|
||||
Ok(Message::Tx {
|
||||
version: Version(reader.read_u32::<LittleEndian>()?),
|
||||
transaction: Box::new(Transaction::zcash_deserialize(&mut reader)?),
|
||||
})
|
||||
fn read_tx<R: Read>(&self, mut rdr: R) -> Result<Message, Error> {
|
||||
Ok(Message::Tx(Box::new(Transaction::zcash_deserialize(rdr)?)))
|
||||
}
|
||||
|
||||
fn read_mempool<R: Read>(&self, mut _reader: R) -> Result<Message, Error> {
|
||||
|
|
|
@ -132,14 +132,7 @@ pub enum Message {
|
|||
/// A `block` message.
|
||||
///
|
||||
/// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#block)
|
||||
Block {
|
||||
/// Transaction data format version (note, this is signed).
|
||||
// XXX does this get folded into the Block struct?
|
||||
version: Version,
|
||||
|
||||
/// The block itself.
|
||||
block: Box<Block>,
|
||||
},
|
||||
Block(Box<Block>),
|
||||
|
||||
/// A `getblocks` message.
|
||||
///
|
||||
|
@ -252,16 +245,7 @@ pub enum Message {
|
|||
/// A `tx` message.
|
||||
///
|
||||
/// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#tx)
|
||||
// `flag` is not included (it's optional), and therefore
|
||||
// `tx_witnesses` aren't either, as they go if `flag` goes.
|
||||
Tx {
|
||||
/// Transaction data format version (note, this is signed).
|
||||
// XXX do we still need this with the transaction data handling?
|
||||
version: Version,
|
||||
|
||||
/// The `Transaction` type itself.
|
||||
transaction: Box<Transaction>,
|
||||
},
|
||||
Tx(Box<Transaction>),
|
||||
|
||||
/// A `mempool` message.
|
||||
///
|
||||
|
|
Loading…
Reference in New Issue