zcash_client_backend: Add `proto::service::TreeState::to_chain_state`
This commit is contained in:
parent
b3d06ba419
commit
7d603b8c59
|
@ -24,12 +24,14 @@ and this library adheres to Rust's notion of
|
|||
- `ORCHARD_SHARD_HEIGHT`
|
||||
- `BlockMetadata::orchard_tree_size`
|
||||
- `WalletSummary::next_orchard_subtree_index`
|
||||
- `chain::ChainState`
|
||||
- `chain::ScanSummary::{spent_orchard_note_count, received_orchard_note_count}`
|
||||
- `zcash_client_backend::fees`:
|
||||
- `orchard`
|
||||
- `ChangeValue::orchard`
|
||||
- `zcash_client_backend::proto`:
|
||||
- `service::TreeState::orchard_tree`
|
||||
- `service::TreeState::to_chain_state`
|
||||
- `impl TryFrom<&CompactOrchardAction> for CompactAction`
|
||||
- `CompactOrchardAction::{cmx, nf, ephemeral_key}`
|
||||
- `zcash_client_backend::scanning`:
|
||||
|
|
|
@ -20,7 +20,7 @@ use zcash_primitives::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
data_api::InputSource,
|
||||
data_api::{chain::ChainState, InputSource},
|
||||
fees::{ChangeValue, TransactionBalance},
|
||||
proposal::{Proposal, ProposalError, ShieldedInputs, Step, StepOutput, StepOutputIndex},
|
||||
zip321::{TransactionRequest, Zip321Error},
|
||||
|
@ -290,6 +290,20 @@ impl service::TreeState {
|
|||
&orchard_tree_bytes[..],
|
||||
)
|
||||
}
|
||||
|
||||
/// Parses this tree state into a [`ChainState`] for use with [`scan_cached_blocks`].
|
||||
///
|
||||
/// [`scan_cached_blocks`]: crate::data_api::chain::scan_cached_blocks
|
||||
pub fn to_chain_state(&self) -> io::Result<ChainState> {
|
||||
Ok(ChainState::new(
|
||||
self.height
|
||||
.try_into()
|
||||
.map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "Invalid block height"))?,
|
||||
self.sapling_tree()?.to_frontier(),
|
||||
#[cfg(feature = "orchard")]
|
||||
self.orchard_tree()?.to_frontier(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
/// Constant for the V1 proposal serialization version.
|
||||
|
|
Loading…
Reference in New Issue