Skip to content

Commit

Permalink
chore(ethexe): impl Clone for NetworkEvent (#4492)
Browse files Browse the repository at this point in the history
  • Loading branch information
breathx authored Feb 7, 2025
1 parent cfe2005 commit 6eb523f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ethexe/network/src/db_sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ enum ResponseValidationError {
DataHashMismatch,
}

#[derive(Debug, Eq, PartialEq, Encode, Decode)]
#[derive(Clone, Debug, Eq, PartialEq, Encode, Decode)]
pub enum Response {
/// Key (hash) - value (bytes) data
DataForHashes(BTreeMap<H256, Vec<u8>>),
Expand Down Expand Up @@ -165,7 +165,7 @@ pub enum NewRequestRoundReason {
PeerFailed,
}

#[derive(Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum RequestFailure {
/// Request exceeded its round limit
OutOfRounds,
Expand Down
16 changes: 15 additions & 1 deletion ethexe/network/src/db_sync/ongoing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub(crate) enum ExternalValidation {
},
}

#[derive(Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ValidatingResponse {
ongoing_request: OngoingRequest,
peer_id: PeerId,
Expand Down Expand Up @@ -107,6 +107,20 @@ pub(crate) struct OngoingRequest {
peer_score_handle: Handle,
}

impl Clone for OngoingRequest {
fn clone(&self) -> Self {
Self {
request_id: self.request_id,
original_request: self.original_request.clone(),
request: self.request.clone(),
response: self.response.clone(),
tried_peers: self.tried_peers.clone(),
timeout: Box::pin(time::sleep_until(self.timeout.deadline())),
peer_score_handle: self.peer_score_handle.clone(),
}
}
}

impl PartialEq for OngoingRequest {
fn eq(&self, other: &Self) -> bool {
self.request_id == other.request_id
Expand Down
2 changes: 1 addition & 1 deletion ethexe/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const MAX_ESTABLISHED_INCOMING_PER_PEER_CONNECTIONS: u32 = 1;
const MAX_ESTABLISHED_OUTBOUND_PER_PEER_CONNECTIONS: u32 = 1;
const MAX_ESTABLISHED_INCOMING_CONNECTIONS: u32 = 100;

#[derive(Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum NetworkEvent {
Message {
source: Option<PeerId>,
Expand Down

0 comments on commit 6eb523f

Please sign in to comment.