zebra_chain::serialization::zcash_deserialize

Function zcash_deserialize_external_count

source
pub fn zcash_deserialize_external_count<R: Read, T: ZcashDeserialize + TrustedPreallocate>(
    external_count: usize,
    reader: R,
) -> Result<Vec<T>, SerializationError>
Expand description

Deserialize a Vec containing external_count items.

In Zcash, most arrays are stored as a CompactSize, followed by that number of items of type T. But in Transaction::V5, some types are serialized as multiple arrays in different locations, with a single CompactSize before the first array.

ยงUsage

Use zcash_deserialize_external_count when the array count is determined by other data, or a consensus rule.

Use Vec::zcash_deserialize for data that contains CompactSize count, followed by the data array.

For example, when a single count applies to multiple arrays:

  1. Use Vec::zcash_deserialize for the array that has a data count.
  2. Use zcash_deserialize_external_count for the arrays with no count in the data, passing the length of the first array.

This function has a zcash_ prefix to alert the reader that the serialization in use is consensus-critical serialization, rather than some other kind of serialization.