feat(storage, tree): respect Sender Recovery pruning in the blockchain tree (#4431)

This commit is contained in:
Alexey Shekhirin
2023-09-05 18:35:14 +01:00
committed by GitHub
parent 3e7e65127f
commit 001cbd7532
2 changed files with 15 additions and 1 deletions

View File

@ -468,6 +468,10 @@ mod tests {
{
let provider = factory.provider_rw().unwrap();
assert_matches!(provider.insert_block(block.clone(), None, None), Ok(_));
assert_matches!(
provider.transaction_sender(0), Ok(Some(sender))
if sender == block.body[0].recover_signer().unwrap()
);
assert_matches!(provider.transaction_id(block.body[0].hash), Ok(Some(0)));
}
@ -478,12 +482,14 @@ mod tests {
block.clone(),
None,
Some(&PruneModes {
sender_recovery: Some(PruneMode::Full),
transaction_lookup: Some(PruneMode::Full),
..PruneModes::none()
})
),
Ok(_)
);
assert_matches!(provider.transaction_sender(0), Ok(None));
assert_matches!(provider.transaction_id(block.body[0].hash), Ok(None));
}
}

View File

@ -1980,7 +1980,15 @@ impl<'this, TX: DbTxMut<'this> + DbTx<'this>> BlockWriter for DatabaseProvider<'
for (transaction, sender) in tx_iter {
let hash = transaction.hash();
self.tx.put::<tables::TxSenders>(next_tx_num, sender)?;
if prune_modes
.and_then(|modes| modes.sender_recovery)
.filter(|prune_mode| prune_mode.is_full())
.is_none()
{
self.tx.put::<tables::TxSenders>(next_tx_num, sender)?;
}
self.tx.put::<tables::Transactions>(next_tx_num, transaction.into())?;
if prune_modes