zcash_client_sqlite: Minor cleanup of `put_blocks` code.
This commit is contained in:
parent
c80e0c7081
commit
2457a14954
|
@ -885,19 +885,27 @@ impl<P: consensus::Parameters> WalletWrite for WalletDb<rusqlite::Connection, P>
|
||||||
orchard_start_position: Position,
|
orchard_start_position: Position,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if blocks.is_empty() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
self.transactionally(|wdb| {
|
self.transactionally(|wdb| {
|
||||||
let start_positions = blocks.first().map(|block| BlockPositions {
|
let initial_block = blocks.first().expect("blocks is known to be nonempty");
|
||||||
height: block.height(),
|
assert!(from_state.block_height() + 1 == initial_block.height());
|
||||||
|
|
||||||
|
let start_positions = BlockPositions {
|
||||||
|
height: initial_block.height(),
|
||||||
sapling_start_position: Position::from(
|
sapling_start_position: Position::from(
|
||||||
u64::from(block.sapling().final_tree_size())
|
u64::from(initial_block.sapling().final_tree_size())
|
||||||
- u64::try_from(block.sapling().commitments().len()).unwrap(),
|
- u64::try_from(initial_block.sapling().commitments().len()).unwrap(),
|
||||||
),
|
),
|
||||||
#[cfg(feature = "orchard")]
|
#[cfg(feature = "orchard")]
|
||||||
orchard_start_position: Position::from(
|
orchard_start_position: Position::from(
|
||||||
u64::from(block.orchard().final_tree_size())
|
u64::from(initial_block.orchard().final_tree_size())
|
||||||
- u64::try_from(block.orchard().commitments().len()).unwrap(),
|
- u64::try_from(initial_block.orchard().commitments().len()).unwrap(),
|
||||||
),
|
),
|
||||||
});
|
};
|
||||||
|
|
||||||
let mut sapling_commitments = vec![];
|
let mut sapling_commitments = vec![];
|
||||||
#[cfg(feature = "orchard")]
|
#[cfg(feature = "orchard")]
|
||||||
let mut orchard_commitments = vec![];
|
let mut orchard_commitments = vec![];
|
||||||
|
@ -1052,9 +1060,7 @@ impl<P: consensus::Parameters> WalletWrite for WalletDb<rusqlite::Connection, P>
|
||||||
|
|
||||||
// We will have a start position and a last scanned height in all cases where
|
// We will have a start position and a last scanned height in all cases where
|
||||||
// `blocks` is non-empty.
|
// `blocks` is non-empty.
|
||||||
if let Some((start_positions, last_scanned_height)) =
|
if let Some(last_scanned_height) = last_scanned_height {
|
||||||
start_positions.zip(last_scanned_height)
|
|
||||||
{
|
|
||||||
// Create subtrees from the note commitments in parallel.
|
// Create subtrees from the note commitments in parallel.
|
||||||
const CHUNK_SIZE: usize = 1024;
|
const CHUNK_SIZE: usize = 1024;
|
||||||
let sapling_subtrees = sapling_commitments
|
let sapling_subtrees = sapling_commitments
|
||||||
|
|
|
@ -16,9 +16,6 @@ use {
|
||||||
zcash_client_backend::data_api::testing::orchard::OrchardPoolTester,
|
zcash_client_backend::data_api::testing::orchard::OrchardPoolTester,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "transparent-inputs")]
|
|
||||||
use crate::error::SqliteClientError;
|
|
||||||
|
|
||||||
pub(crate) trait ShieldedPoolPersistence {
|
pub(crate) trait ShieldedPoolPersistence {
|
||||||
const TABLES_PREFIX: &'static str;
|
const TABLES_PREFIX: &'static str;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +44,7 @@ pub(crate) fn send_multi_step_proposed_transfer<T: ShieldedPoolTester>() {
|
||||||
|e, account_id, expected_bad_index| {
|
|e, account_id, expected_bad_index| {
|
||||||
matches!(
|
matches!(
|
||||||
e,
|
e,
|
||||||
SqliteClientError::ReachedGapLimit(acct, bad_index)
|
crate::error::SqliteClientError::ReachedGapLimit(acct, bad_index)
|
||||||
if acct == &account_id && bad_index == &expected_bad_index)
|
if acct == &account_id && bad_index == &expected_bad_index)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue