Skip to content

Commit fb1f34a

Browse files
committed
refactor(snark_pool_candidate): Combine all action types of the snark_pool_candidate module into the parent action type
1 parent 931377e commit fb1f34a

File tree

6 files changed

+222
-325
lines changed

6 files changed

+222
-325
lines changed

node/src/effects.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ use crate::p2p::discovery::{P2pDiscoveryKademliaBootstrapAction, P2pDiscoveryKad
2121
use crate::p2p::p2p_effects;
2222
use crate::rpc::rpc_effects;
2323
use crate::snark::snark_effects;
24-
use crate::snark_pool::candidate::{
25-
SnarkPoolCandidateWorkFetchAllAction, SnarkPoolCandidateWorkVerifyNextAction,
26-
};
24+
use crate::snark_pool::candidate::SnarkPoolCandidateAction;
2725
use crate::snark_pool::{
2826
snark_pool_effects, SnarkPoolCheckTimeoutsAction, SnarkPoolP2pSendAllAction,
2927
};
@@ -62,8 +60,8 @@ pub fn effects<S: Service>(store: &mut Store<S>, action: ActionWithMeta) {
6260

6361
p2p_request_best_tip_if_needed(store);
6462

65-
store.dispatch(SnarkPoolCandidateWorkFetchAllAction {});
66-
store.dispatch(SnarkPoolCandidateWorkVerifyNextAction {});
63+
store.dispatch(SnarkPoolCandidateAction::WorkFetchAll {});
64+
store.dispatch(SnarkPoolCandidateAction::WorkVerifyNext {});
6765

6866
p2p_request_snarks_if_needed(store);
6967

node/src/p2p/p2p_effects.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ use crate::rpc::{
77
RpcP2pConnectionIncomingSuccessAction, RpcP2pConnectionOutgoingErrorAction,
88
RpcP2pConnectionOutgoingSuccessAction,
99
};
10-
use crate::snark_pool::candidate::{
11-
SnarkPoolCandidateInfoReceivedAction, SnarkPoolCandidatePeerPruneAction,
12-
SnarkPoolCandidateWorkReceivedAction,
13-
};
10+
use crate::snark_pool::candidate::SnarkPoolCandidateAction;
1411
use crate::snark_pool::SnarkPoolJobCommitmentAddAction;
1512
use crate::transition_frontier::sync::ledger::snarked::{
1613
PeerLedgerQueryError, PeerLedgerQueryResponse,
@@ -262,7 +259,7 @@ pub fn p2p_effects<S: Service>(store: &mut Store<S>, action: P2pActionWithMeta)
262259
store.dispatch(action);
263260
}
264261

265-
store.dispatch(SnarkPoolCandidatePeerPruneAction {
262+
store.dispatch(SnarkPoolCandidateAction::PeerPrune {
266263
peer_id: action.peer_id,
267264
});
268265
}
@@ -356,7 +353,7 @@ pub fn p2p_effects<S: Service>(store: &mut Store<S>, action: P2pActionWithMeta)
356353
P2pChannelsSnarkAction::PromiseReceived(_) => {}
357354
P2pChannelsSnarkAction::Received(action) => {
358355
action.effects(&meta, store);
359-
store.dispatch(SnarkPoolCandidateInfoReceivedAction {
356+
store.dispatch(SnarkPoolCandidateAction::InfoReceived {
360357
peer_id: action.peer_id,
361358
info: action.snark,
362359
});
@@ -366,7 +363,7 @@ pub fn p2p_effects<S: Service>(store: &mut Store<S>, action: P2pActionWithMeta)
366363
action.effects(&meta, store);
367364
}
368365
P2pChannelsSnarkAction::Libp2pReceived(action) => {
369-
store.dispatch(SnarkPoolCandidateWorkReceivedAction {
366+
store.dispatch(SnarkPoolCandidateAction::WorkReceived {
370367
peer_id: action.peer_id,
371368
work: action.snark,
372369
});
@@ -541,7 +538,7 @@ pub fn p2p_effects<S: Service>(store: &mut Store<S>, action: P2pActionWithMeta)
541538
});
542539
}
543540
Some(P2pRpcResponse::Snark(snark)) => {
544-
store.dispatch(SnarkPoolCandidateWorkReceivedAction {
541+
store.dispatch(SnarkPoolCandidateAction::WorkReceived {
545542
peer_id: action.peer_id,
546543
work: snark.clone(),
547544
});

node/src/snark/snark_effects.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use crate::consensus::ConsensusBlockSnarkVerifySuccessAction;
2-
use crate::snark_pool::candidate::{
3-
SnarkPoolCandidateWorkVerifyErrorAction, SnarkPoolCandidateWorkVerifySuccessAction,
4-
};
2+
use crate::snark_pool::candidate::SnarkPoolCandidateAction;
53
use crate::snark_pool::SnarkPoolWorkAddAction;
64
use crate::{Service, Store};
75

@@ -41,7 +39,7 @@ pub fn snark_effects<S: Service>(store: &mut Store<S>, action: SnarkActionWithMe
4139
let Some(req) = req else { return };
4240
let sender = req.sender().parse().unwrap();
4341

44-
store.dispatch(SnarkPoolCandidateWorkVerifyErrorAction {
42+
store.dispatch(SnarkPoolCandidateAction::WorkVerifyError {
4543
peer_id: sender,
4644
verify_id: a.req_id,
4745
});
@@ -53,7 +51,7 @@ pub fn snark_effects<S: Service>(store: &mut Store<S>, action: SnarkActionWithMe
5351
let sender = req.sender().parse().unwrap();
5452
let batch = req.batch().to_vec();
5553

56-
store.dispatch(SnarkPoolCandidateWorkVerifySuccessAction {
54+
store.dispatch(SnarkPoolCandidateAction::WorkVerifySuccess {
5755
peer_id: sender,
5856
verify_id: a.req_id,
5957
});

0 commit comments

Comments
 (0)