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(BOUN-1236): implement secret tracking #2433

Open
wants to merge 1 commit into
base: or-salt-log-5
Choose a base branch
from

Conversation

rikonor
Copy link
Contributor

@rikonor rikonor commented Nov 4, 2024

This change adds a Tracker implementation for the client of the canister. This allows one to instantiate a tracker that will follow the current secret value from the canister, as well as participate in leader duties for secret generation (i.e if you as a client have been chosen as a leader, you will be required to generate the salt and encrypt it for other peers).

@rikonor rikonor self-assigned this Nov 4, 2024
@rikonor rikonor requested a review from a team as a code owner November 4, 2024 22:32
@github-actions github-actions bot added the feat label Nov 4, 2024
Copy link
Contributor

@nikolay-komarevskiy nikolay-komarevskiy left a comment

Choose a reason for hiding this comment

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

LGTM

async fn track(&mut self, cb: impl Fn(Vec<u8>) + Send + Sync) -> Result<(), Error>;
}

pub struct Tracker {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: SaltTracker

impl Track for Tracker {
async fn track(&mut self, cb: impl Fn(Vec<u8>) + Send + Sync) -> Result<(), Error> {
// Register public-key
loop {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider having delays and probably max retries.

}
}

loop {
Copy link
Contributor

Choose a reason for hiding this comment

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

You seem to do one loop after the other, maybe use one loop then? Is it ok to get stuck in this loop forever?

Copy link
Contributor

Choose a reason for hiding this comment

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

Since this function is relatively long, consider breaking it down into smaller ones. This would improve readability and make the function logic cleaner.


#[async_trait]
pub trait Track: Sync + Send {
async fn track(&mut self, cb: impl Fn(Vec<u8>) + Send + Sync) -> Result<(), Error>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to make this trait immutable and simply return the salt, and have another struct e.g. PeriodicTracker, which would execute this track() in a loop?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants