Handle parsing of the not-present `CommitmentTree` sentinel.
This commit is contained in:
parent
70497a241c
commit
8625e9a777
|
@ -108,6 +108,8 @@ pub(crate) mod commitment_tree;
|
||||||
pub mod init;
|
pub mod init;
|
||||||
pub(crate) mod sapling;
|
pub(crate) mod sapling;
|
||||||
|
|
||||||
|
pub(crate) const BLOCK_SAPLING_FRONTIER_ABSENT: &[u8] = &[0x0];
|
||||||
|
|
||||||
pub(crate) fn pool_code(pool_type: PoolType) -> i64 {
|
pub(crate) fn pool_code(pool_type: PoolType) -> i64 {
|
||||||
// These constants are *incidentally* shared with the typecodes
|
// These constants are *incidentally* shared with the typecodes
|
||||||
// for unified addresses, but this is exclusively an internal
|
// for unified addresses, but this is exclusively an internal
|
||||||
|
@ -563,23 +565,29 @@ pub(crate) fn fully_scanned_height(
|
||||||
.optional()?;
|
.optional()?;
|
||||||
|
|
||||||
res_opt
|
res_opt
|
||||||
.map(|(max_height, sapling_tree_size, sapling_tree)| {
|
.and_then(|(max_height, sapling_tree_size, sapling_tree)| {
|
||||||
let commitment_tree_meta =
|
sapling_tree_size
|
||||||
CommitmentTreeMeta::from_parts(if let Some(known_size) = sapling_tree_size {
|
.map(|s| Ok(CommitmentTreeMeta::from_parts(s)))
|
||||||
known_size
|
.or_else(|| {
|
||||||
|
if &sapling_tree == BLOCK_SAPLING_FRONTIER_ABSENT {
|
||||||
|
None
|
||||||
} else {
|
} else {
|
||||||
// parse the legacy commitment tree data
|
// parse the legacy commitment tree data
|
||||||
read_commitment_tree::<
|
read_commitment_tree::<
|
||||||
zcash_primitives::sapling::Node,
|
zcash_primitives::sapling::Node,
|
||||||
_,
|
_,
|
||||||
{ zcash_primitives::sapling::NOTE_COMMITMENT_TREE_DEPTH },
|
{ zcash_primitives::sapling::NOTE_COMMITMENT_TREE_DEPTH },
|
||||||
>(Cursor::new(sapling_tree))?
|
>(Cursor::new(sapling_tree))
|
||||||
.size()
|
.map(|tree| {
|
||||||
.try_into()
|
Some(CommitmentTreeMeta::from_parts(
|
||||||
.expect("usize values are convertible to u64 on all supported platforms.")
|
tree.size().try_into().unwrap(),
|
||||||
});
|
))
|
||||||
|
})
|
||||||
Ok((max_height, commitment_tree_meta))
|
.map_err(SqliteClientError::from)
|
||||||
|
.transpose()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map(|meta_res| meta_res.map(|meta| (max_height, meta)))
|
||||||
})
|
})
|
||||||
.transpose()
|
.transpose()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue