-
Notifications
You must be signed in to change notification settings - Fork 41
Ported reducer and p2p effects in node #784
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| mod p2p_callbacks_actions; | ||
| pub use p2p_callbacks_actions::P2pCallbacksAction; | ||
| mod p2p_callbacks_reducer; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| use openmina_core::ActionEvent; | ||
| use p2p::{ | ||
| channels::{ | ||
| rpc::{P2pRpcId, P2pRpcRequest, P2pRpcResponse}, | ||
| streaming_rpc::P2pStreamingRpcResponseFull, | ||
| }, | ||
| PeerId, | ||
| }; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| #[derive(Serialize, Deserialize, Debug, Clone, ActionEvent)] | ||
| #[action_event(level = debug)] | ||
| pub enum P2pCallbacksAction { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these callbacks RPC related only? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Callbacks are optional because of p2p tests, |
||
| P2pChannelsRpcReady { | ||
| peer_id: PeerId, | ||
| }, | ||
| P2pChannelsRpcTimeout { | ||
| peer_id: PeerId, | ||
| id: P2pRpcId, | ||
| }, | ||
| P2pChannelsRpcResponseReceived { | ||
| peer_id: PeerId, | ||
| id: P2pRpcId, | ||
| response: Option<Box<P2pRpcResponse>>, | ||
| }, | ||
| P2pChannelsRpcRequestReceived { | ||
| peer_id: PeerId, | ||
| id: P2pRpcId, | ||
| request: Box<P2pRpcRequest>, | ||
| }, | ||
|
|
||
| P2pChannelsStreamingRpcReady, | ||
| P2pChannelsStreamingRpcTimeout { | ||
| peer_id: PeerId, | ||
| id: P2pRpcId, | ||
| }, | ||
| P2pChannelsStreamingRpcResponseReceived { | ||
| peer_id: PeerId, | ||
| id: P2pRpcId, | ||
| response: Option<P2pStreamingRpcResponseFull>, | ||
| }, | ||
|
|
||
| P2pDisconnection { | ||
| peer_id: PeerId, | ||
| }, | ||
| RpcRespondBestTip { | ||
| peer_id: PeerId, | ||
| }, | ||
| } | ||
|
|
||
| impl redux::EnablingCondition<crate::State> for P2pCallbacksAction { | ||
| fn is_enabled(&self, state: &crate::State, _time: redux::Timestamp) -> bool { | ||
| match self { | ||
| P2pCallbacksAction::P2pChannelsRpcReady { .. } => true, | ||
0xMimir marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| P2pCallbacksAction::P2pChannelsRpcTimeout { .. } => true, | ||
| P2pCallbacksAction::P2pChannelsRpcResponseReceived { .. } => true, | ||
| P2pCallbacksAction::P2pChannelsRpcRequestReceived { .. } => true, | ||
| P2pCallbacksAction::P2pChannelsStreamingRpcReady => true, | ||
| P2pCallbacksAction::P2pChannelsStreamingRpcTimeout { .. } => true, | ||
| P2pCallbacksAction::P2pChannelsStreamingRpcResponseReceived { .. } => true, | ||
| P2pCallbacksAction::P2pDisconnection { .. } => true, | ||
| // TODO: what if we don't have best tip? | ||
| P2pCallbacksAction::RpcRespondBestTip { .. } => { | ||
| state.transition_frontier.best_tip().is_some() | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.