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)?,
|
Addr(ref addrs) => addrs.zcash_serialize(&mut writer)?,
|
||||||
GetAddr => { /* Empty payload -- no-op */ }
|
GetAddr => { /* Empty payload -- no-op */ }
|
||||||
Block {
|
Block(ref block) => block.zcash_serialize(&mut writer)?,
|
||||||
ref version,
|
|
||||||
ref block,
|
|
||||||
} => {
|
|
||||||
writer.write_u32::<LittleEndian>(version.0)?;
|
|
||||||
block.zcash_serialize(&mut writer)?
|
|
||||||
}
|
|
||||||
GetBlocks {
|
GetBlocks {
|
||||||
ref version,
|
ref version,
|
||||||
ref block_locator_hashes,
|
ref block_locator_hashes,
|
||||||
|
@ -232,13 +226,7 @@ impl Codec {
|
||||||
Inv(ref hashes) => hashes.zcash_serialize(&mut writer)?,
|
Inv(ref hashes) => hashes.zcash_serialize(&mut writer)?,
|
||||||
GetData(ref hashes) => hashes.zcash_serialize(&mut writer)?,
|
GetData(ref hashes) => hashes.zcash_serialize(&mut writer)?,
|
||||||
NotFound(ref hashes) => hashes.zcash_serialize(&mut writer)?,
|
NotFound(ref hashes) => hashes.zcash_serialize(&mut writer)?,
|
||||||
Tx {
|
Tx(ref transaction) => transaction.zcash_serialize(&mut writer)?,
|
||||||
ref version,
|
|
||||||
ref transaction,
|
|
||||||
} => {
|
|
||||||
writer.write_u32::<LittleEndian>(version.0)?;
|
|
||||||
transaction.zcash_serialize(&mut writer)?
|
|
||||||
}
|
|
||||||
Mempool => { /* Empty payload -- no-op */ }
|
Mempool => { /* Empty payload -- no-op */ }
|
||||||
FilterLoad {
|
FilterLoad {
|
||||||
ref filter,
|
ref filter,
|
||||||
|
@ -465,10 +453,7 @@ impl Codec {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_block<R: Read>(&self, mut reader: R) -> Result<Message, Error> {
|
fn read_block<R: Read>(&self, mut reader: R) -> Result<Message, Error> {
|
||||||
Ok(Message::Block {
|
Ok(Message::Block(Box::new(Block::zcash_deserialize(reader)?)))
|
||||||
version: Version(reader.read_u32::<LittleEndian>()?),
|
|
||||||
block: Box::new(Block::zcash_deserialize(&mut reader)?),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_getblocks<R: Read>(&self, mut reader: R) -> Result<Message, Error> {
|
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)?))
|
Ok(Message::NotFound(Vec::zcash_deserialize(reader)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_tx<R: Read>(&self, mut reader: R) -> Result<Message, Error> {
|
fn read_tx<R: Read>(&self, mut rdr: R) -> Result<Message, Error> {
|
||||||
Ok(Message::Tx {
|
Ok(Message::Tx(Box::new(Transaction::zcash_deserialize(rdr)?)))
|
||||||
version: Version(reader.read_u32::<LittleEndian>()?),
|
|
||||||
transaction: Box::new(Transaction::zcash_deserialize(&mut reader)?),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_mempool<R: Read>(&self, mut _reader: R) -> Result<Message, Error> {
|
fn read_mempool<R: Read>(&self, mut _reader: R) -> Result<Message, Error> {
|
||||||
|
|
|
@ -132,14 +132,7 @@ pub enum Message {
|
||||||
/// A `block` message.
|
/// A `block` message.
|
||||||
///
|
///
|
||||||
/// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#block)
|
/// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#block)
|
||||||
Block {
|
Block(Box<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>,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// A `getblocks` message.
|
/// A `getblocks` message.
|
||||||
///
|
///
|
||||||
|
@ -252,16 +245,7 @@ pub enum Message {
|
||||||
/// A `tx` message.
|
/// A `tx` message.
|
||||||
///
|
///
|
||||||
/// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#tx)
|
/// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#tx)
|
||||||
// `flag` is not included (it's optional), and therefore
|
Tx(Box<Transaction>),
|
||||||
// `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>,
|
|
||||||
},
|
|
||||||
|
|
||||||
/// A `mempool` message.
|
/// A `mempool` message.
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue