You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider using a reference for EnclaveEvent in EventHook
The EventHook type and E3RequestRouter struct changes align well with the new event handling mechanism. However, the EventHook type now takes ownership of the EnclaveEvent, which might lead to unnecessary cloning.
Consider changing the EventHook type to use a reference to EnclaveEvent:
-pub type EventHook = Box<dyn FnMut(&mut E3RequestContext, EnclaveEvent)>;+pub type EventHook = Box<dyn FnMut(&mut E3RequestContext, &EnclaveEvent)>;
This change would require updating the handle method in the Handler<EnclaveEvent> implementation for E3RequestRouter to pass a reference to msg instead of cloning it.
📝 Committable suggestion
‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
/// Format of the hook that needs to be passed to E3RequestRouter
pub type EventHook = Box<dyn FnMut(&mut E3RequestContext, &EnclaveEvent)>;
/// E3RequestRouter will register hooks that receive an E3_id specific context. After hooks
/// have run e3_id specific messages are forwarded to all instances on the context. This enables
/// hooks to lazily register instances that have the correct dependencies available per e3_id
/// request
// TODO: setup typestate pattern so that we have to place hooks within correct order of
// dependencies
pub struct E3RequestRouter {
contexts: HashMap<E3id, E3RequestContext>,
hooks: Vec<EventHook>,
buffer: EventBuffer,
}
Consider using a reference for EnclaveEvent in EventHook
The
EventHook
type andE3RequestRouter
struct changes align well with the new event handling mechanism. However, theEventHook
type now takes ownership of theEnclaveEvent
, which might lead to unnecessary cloning.Consider changing the
EventHook
type to use a reference toEnclaveEvent
:This change would require updating the
handle
method in theHandler<EnclaveEvent>
implementation forE3RequestRouter
to pass a reference tomsg
instead of cloning it.📝 Committable suggestion
Originally posted by @coderabbitai[bot] in #133 (comment)
The text was updated successfully, but these errors were encountered: