-
Notifications
You must be signed in to change notification settings - Fork 22
feat: prefactor for sync mode tidy up event structure [skip-line-limit] #1056
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
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
63dd7a5
prefactor enclave event
a376534
formatting
067a4b5
compiling
5778792
ensure compilation and fix errors
aebcd86
fix unused var
4755e33
use strum for event type
e0a55a8
fix shutdown pattern
8635caf
update core types
ae886a3
manager types and refactor wip
8678fc1
stable abstraction
49e8e24
fix up traits and types
61c09a7
major refactor of eventing
810711f
add license
2b5dc43
fix test compilation
5eb29d0
rename event manager
cf54412
format
49425da
ManagedEvent -> CompositeEvent
78453b2
remove import
30710a0
create_local -> event_from
299ac15
fix api design
840fc2c
update api design to use pubsub terminology
fd3b2a2
event_manager.rs -> bus_handle.rs
c27fc40
event_manager.rs -> bus_handle.rs
4500220
event_manager.rs -> bus_handle.rs
876a1be
add comments
bf7f2e5
remove FromError
b230565
i know this sounds crazy but hear me out...
851f856
remove unused imports
e36a9c0
add required type constraints
55c0860
Merge branch 'main' into ry/1050-eventsourcing-clocks
ryardley 75abb34
Merge branch 'main' into ry/1050-eventsourcing-clocks
ryardley 14ea698
add wait for poseidon
5e96380
remove logging
a860e87
add logging
10cb525
add logging
f9be99e
try buffering keyshare created events
71fc523
headers
af374f0
public key aggregator does not need sortition
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // SPDX-License-Identifier: LGPL-3.0-only | ||
| // | ||
| // This file is provided WITHOUT ANY WARRANTY; | ||
| // without even the implied warranty of MERCHANTABILITY | ||
| // or FITNESS FOR A PARTICULAR PURPOSE. | ||
|
|
||
| use actix::prelude::*; | ||
|
|
||
| use e3_events::{prelude::*, EnclaveEvent, EnclaveEventData}; | ||
| use std::collections::HashSet; | ||
|
|
||
| use crate::PublicKeyAggregator; | ||
|
|
||
| /// Buffer KeyshareCreated events until CommitteeFinalized has been published | ||
| pub struct KeyshareCreatedFilterBuffer { | ||
| dest: Addr<PublicKeyAggregator>, | ||
| committee: Option<HashSet<String>>, | ||
| buffer: Vec<EnclaveEvent>, | ||
| } | ||
|
|
||
| impl KeyshareCreatedFilterBuffer { | ||
| pub fn new(dest: Addr<PublicKeyAggregator>) -> Self { | ||
| Self { | ||
| dest, | ||
| committee: None, | ||
| buffer: Vec::new(), | ||
| } | ||
| } | ||
|
|
||
| fn process_buffered_events(&mut self) { | ||
| if let Some(ref committee) = self.committee { | ||
| for event in self.buffer.drain(..) { | ||
| if let EnclaveEventData::KeyshareCreated(data) = event.get_data() { | ||
| if committee.contains(&data.node) { | ||
| self.dest.do_send(event); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl Actor for KeyshareCreatedFilterBuffer { | ||
| type Context = Context<Self>; | ||
| } | ||
|
|
||
| impl Handler<EnclaveEvent> for KeyshareCreatedFilterBuffer { | ||
| type Result = (); | ||
|
|
||
| fn handle(&mut self, msg: EnclaveEvent, _ctx: &mut Self::Context) -> Self::Result { | ||
| match msg.get_data() { | ||
| EnclaveEventData::KeyshareCreated(data) => match &self.committee { | ||
| Some(committee) if committee.contains(&data.node) => { | ||
| // if the committee is ready then process | ||
| self.dest.do_send(msg); | ||
| } | ||
| None => { | ||
| // if not buffer | ||
| self.buffer.push(msg); | ||
| } | ||
| _ => {} | ||
| }, | ||
| EnclaveEventData::CommitteeFinalized(data) => { | ||
| self.dest.do_send(msg.clone()); // forward committee first | ||
| self.committee = Some(data.committee.iter().cloned().collect()); | ||
| self.process_buffered_events(); | ||
| } | ||
| _ => { | ||
| // forward all other events | ||
| self.dest.do_send(msg); | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.