Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): save delegations/revocations in batch #14

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

merklefruit
Copy link

No description provided.

Comment on lines +577 to +593
for signed_revocation in &signed_revocations {
let key = get_delegations_key(&signed_revocation.message.validator_pubkey);

// Attempt to get the existing delegations from the cache.
let mut delegations: Vec<SignedDelegation> =
self.get(&key).await.map_err(AuctioneerError::RedisError)?.unwrap_or_default();

// Filter out the revoked delegation.
let updated_delegations = delegations.retain(|delegation| {
signed_revocations.iter().all(|revocation| {
delegation.message.delegatee_pubkey != revocation.message.delegatee_pubkey
})
});

// Save the updated delegations back to the cache.
self.set(&key, &updated_delegations, None).await.map_err(AuctioneerError::RedisError)?;
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo(self): double check logic

Copy link
Collaborator

@thedevbirb thedevbirb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit!

crates/api/src/constraints/api.rs Outdated Show resolved Hide resolved
crates/api/src/constraints/api.rs Outdated Show resolved Hide resolved
@merklefruit
Copy link
Author

thanks, addressed

@thedevbirb thedevbirb merged commit 95d8c04 into naman/feat/constraints-api-new Oct 17, 2024
1 check passed
@thedevbirb thedevbirb deleted the nico/chore/delegations-vec branch October 17, 2024 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants