-
Notifications
You must be signed in to change notification settings - Fork 318
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
base: or-salt-log-5
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>; |
There was a problem hiding this comment.
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?
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).