Rename proto::compact::{BlockMetadata => ChainMetadata}
This commit is contained in:
parent
42ed6ba2a1
commit
c363e71fa9
|
@ -13,7 +13,7 @@ option swift_prefix = "";
|
|||
// BlockMetadata represents information about a block that may not be
|
||||
// represented directly in the block data, but is instead derived from chain
|
||||
// data or other external sources.
|
||||
message BlockMetadata {
|
||||
message ChainMetadata {
|
||||
uint32 saplingCommitmentTreeSize = 1; // the size of the Sapling note commitment tree as of the end of this block
|
||||
uint32 orchardCommitmentTreeSize = 2; // the size of the Orchard note commitment tree as of the end of this block
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ message CompactBlock {
|
|||
uint32 time = 5; // Unix epoch time when the block was mined
|
||||
bytes header = 6; // (hash, prevHash, and time) OR (full header)
|
||||
repeated CompactTx vtx = 7; // zero or more compact transactions from this block
|
||||
BlockMetadata blockMetadata = 8; // information about this block derived from the chain or other sources
|
||||
ChainMetadata chainMetadata = 8; // information about the state of the chain as of this block
|
||||
}
|
||||
|
||||
// CompactTx contains the minimum information for a wallet to know if this transaction
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/// data or other external sources.
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct BlockMetadata {
|
||||
pub struct ChainMetadata {
|
||||
/// the size of the Sapling note commitment tree as of the end of this block
|
||||
#[prost(uint32, tag = "1")]
|
||||
pub sapling_commitment_tree_size: u32,
|
||||
|
@ -39,9 +39,9 @@ pub struct CompactBlock {
|
|||
/// zero or more compact transactions from this block
|
||||
#[prost(message, repeated, tag = "7")]
|
||||
pub vtx: ::prost::alloc::vec::Vec<CompactTx>,
|
||||
/// information about this block derived from the chain or other sources
|
||||
/// information about the state of the chain as of this block
|
||||
#[prost(message, optional, tag = "8")]
|
||||
pub block_metadata: ::core::option::Option<BlockMetadata>,
|
||||
pub chain_metadata: ::core::option::Option<ChainMetadata>,
|
||||
}
|
||||
/// CompactTx contains the minimum information for a wallet to know if this transaction
|
||||
/// is relevant to it (either pays to it or spends from it) via shielded elements
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/// data or other external sources.
|
||||
#[allow(clippy::derive_partial_eq_without_eq)]
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct BlockMetadata {
|
||||
pub struct ChainMetadata {
|
||||
/// the size of the Sapling note commitment tree as of the end of this block
|
||||
#[prost(uint32, tag = "1")]
|
||||
pub sapling_commitment_tree_size: u32,
|
||||
|
|
|
@ -264,7 +264,7 @@ pub(crate) fn scan_block_with_runner<
|
|||
// the block, and we can't have a note of ours in a block with no outputs so treating the zero
|
||||
// default value from the protobuf as `None` is always correct.
|
||||
let mut sapling_commitment_tree_size = block
|
||||
.block_metadata
|
||||
.chain_metadata
|
||||
.as_ref()
|
||||
.and_then(|m| {
|
||||
if m.sapling_commitment_tree_size == 0 {
|
||||
|
@ -592,7 +592,7 @@ mod tests {
|
|||
cb.vtx.push(tx);
|
||||
}
|
||||
|
||||
cb.block_metadata = initial_sapling_tree_size.map(|s| compact::BlockMetadata {
|
||||
cb.chain_metadata = initial_sapling_tree_size.map(|s| compact::ChainMetadata {
|
||||
sapling_commitment_tree_size: s + cb
|
||||
.vtx
|
||||
.iter()
|
||||
|
|
|
@ -1107,7 +1107,7 @@ mod tests {
|
|||
};
|
||||
cb.prev_hash.extend_from_slice(&prev_hash.0);
|
||||
cb.vtx.push(ctx);
|
||||
cb.block_metadata = Some(compact::BlockMetadata {
|
||||
cb.chain_metadata = Some(compact::ChainMetadata {
|
||||
sapling_commitment_tree_size: initial_sapling_tree_size
|
||||
+ cb.vtx.iter().map(|tx| tx.outputs.len() as u32).sum::<u32>(),
|
||||
..Default::default()
|
||||
|
@ -1198,7 +1198,7 @@ mod tests {
|
|||
};
|
||||
cb.prev_hash.extend_from_slice(&prev_hash.0);
|
||||
cb.vtx.push(ctx);
|
||||
cb.block_metadata = Some(compact::BlockMetadata {
|
||||
cb.chain_metadata = Some(compact::ChainMetadata {
|
||||
sapling_commitment_tree_size: initial_sapling_tree_size
|
||||
+ cb.vtx.iter().map(|tx| tx.outputs.len() as u32).sum::<u32>(),
|
||||
..Default::default()
|
||||
|
|
Loading…
Reference in New Issue