mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-08-01 02:23:21 +00:00
refactor(wallet): inline the hit loop in sync_updates_via_nullifiers
This commit is contained in:
parent
d2633af413
commit
b6e148249e
@ -372,24 +372,18 @@ impl UserKeyChain {
|
|||||||
message: &Message,
|
message: &Message,
|
||||||
index: &mut NullifierIndex,
|
index: &mut NullifierIndex,
|
||||||
) -> HashSet<usize> {
|
) -> HashSet<usize> {
|
||||||
// Get the nullifier information if awaiting the nullifier.
|
|
||||||
let hits: Vec<(usize, Nullifier, AccountId)> = message
|
|
||||||
.new_nullifiers
|
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.filter_map(|(i, (nullifier, _))| {
|
|
||||||
index.account_for(nullifier).map(|id| (i, *nullifier, id))
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let mut handled = HashSet::new();
|
let mut handled = HashSet::new();
|
||||||
for (i, old_nullifier, account_id) in hits {
|
for (i, (old_nullifier, _)) in message.new_nullifiers.iter().enumerate() {
|
||||||
|
// Get the nullifier information if awaiting the nullifier.
|
||||||
|
let Some(account_id) = index.account_for(old_nullifier) else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
// Try decrypting the commitment connectted to the nullifier and get the next
|
// Try decrypting the commitment connectted to the nullifier and get the next
|
||||||
// nullifier to await.
|
// nullifier to await.
|
||||||
if let Some(new_nullifier) = self.apply_nullifier_update(account_id, message, i) {
|
if let Some(new_nullifier) = self.apply_nullifier_update(account_id, message, i) {
|
||||||
// Update the index to await for the new state of the account, i.e.
|
// Update the index to await for the new state of the account, i.e.
|
||||||
// the new nullifier.
|
// the new nullifier.
|
||||||
index.update(&old_nullifier, new_nullifier, account_id);
|
index.update(old_nullifier, new_nullifier, account_id);
|
||||||
// Record that this nullifier's position can be skipped for scanning.
|
// Record that this nullifier's position can be skipped for scanning.
|
||||||
handled.insert(i);
|
handled.insert(i);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user