Make Message.Block just point at a Block type, in codec call block.zcash_serialize()
This commit is contained in:
parent
df5a5f56dd
commit
35f03dc55d
|
@ -9,7 +9,7 @@ use failure::Error;
|
||||||
use tokio::codec::{Decoder, Encoder};
|
use tokio::codec::{Decoder, Encoder};
|
||||||
|
|
||||||
use zebra_chain::{
|
use zebra_chain::{
|
||||||
serialization::{ReadZcashExt, WriteZcashExt},
|
serialization::{ReadZcashExt, WriteZcashExt, ZcashSerialize},
|
||||||
types::{BlockHeight, Sha256dChecksum},
|
types::{BlockHeight, Sha256dChecksum},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -197,6 +197,11 @@ impl Codec {
|
||||||
Pong(nonce) => {
|
Pong(nonce) => {
|
||||||
writer.write_u64::<LittleEndian>(nonce.0)?;
|
writer.write_u64::<LittleEndian>(nonce.0)?;
|
||||||
}
|
}
|
||||||
|
Block { ref block } => {
|
||||||
|
block
|
||||||
|
.zcash_serialize(&mut writer)
|
||||||
|
.expect("Blocks must serialize.");
|
||||||
|
}
|
||||||
_ => bail!("unimplemented message type"),
|
_ => bail!("unimplemented message type"),
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -136,38 +136,8 @@ pub enum Message {
|
||||||
///
|
///
|
||||||
/// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#block)
|
/// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#block)
|
||||||
Block {
|
Block {
|
||||||
/// Block version information (note, this is signed).
|
/// The block itself.
|
||||||
version: Version,
|
block: Block,
|
||||||
|
|
||||||
/// 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>,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/// A `getblocks` message.
|
/// A `getblocks` message.
|
||||||
|
|
Loading…
Reference in New Issue