Make Message.Block just point at a Block type, in codec call block.zcash_serialize()

This commit is contained in:
Deirdre Connolly 2019-09-26 22:39:04 -04:00 committed by Deirdre Connolly
parent df5a5f56dd
commit 35f03dc55d
2 changed files with 8 additions and 33 deletions

View File

@ -9,7 +9,7 @@ use failure::Error;
use tokio::codec::{Decoder, Encoder};
use zebra_chain::{
serialization::{ReadZcashExt, WriteZcashExt},
serialization::{ReadZcashExt, WriteZcashExt, ZcashSerialize},
types::{BlockHeight, Sha256dChecksum},
};
@ -197,6 +197,11 @@ impl Codec {
Pong(nonce) => {
writer.write_u64::<LittleEndian>(nonce.0)?;
}
Block { ref block } => {
block
.zcash_serialize(&mut writer)
.expect("Blocks must serialize.");
}
_ => bail!("unimplemented message type"),
}
Ok(())

View File

@ -136,38 +136,8 @@ pub enum Message {
///
/// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#block)
Block {
/// Block version information (note, this is signed).
version: Version,
/// The hash value of the previous block (header) this
/// particular block references.
prev_block: BlockHeaderHash,
/// The reference to a Merkle tree collection which is a hash
/// of all transactions related to this block.
merkle_root: MerkleRootHash,
/// The root of the Sapling note commitment tree corresponding
/// to the final Sapling treestate of this block.
// TODO: more than just an array of bytes.
final_sapling_root: [u8; 32],
/// A Unix timestamp recording when this block was created.
time: DateTime<Utc>,
/// The calculated difficulty target being used for this
/// block.
bits: u32,
/// The nonce used to generate this block, to allow variations
/// of the header and compute different hashes.
nonce: [u8; 32],
/// The Equihash solution.
solution: Vec<u8>,
/// Transactions.
txns: Vec<Transaction>,
/// The block itself.
block: Block,
},
/// A `getblocks` message.