Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
SWvheerden committed Jan 10, 2025
1 parent 6f6ddf0 commit 68b3248
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 30 deletions.
53 changes: 26 additions & 27 deletions src/server/p2p/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,7 @@ use tokio::{
};

use super::{
messages::{
CatchUpSyncRequest,
CatchUpSyncResponse,
MetaDataRequest,
MetaDataResponse,
NotifyNewTipBlock,
},
messages::{CatchUpSyncRequest, CatchUpSyncResponse, MetaDataRequest, MetaDataResponse, NotifyNewTipBlock},
setup,
};
use crate::{
Expand All @@ -74,7 +68,14 @@ use crate::{
http::stats_collector::StatsBroadcastClient,
p2p::{
client::ServiceClient,
messages::{self, PeerInfo, SyncMissingBlocksRequest, SyncMissingBlocksResponse},
messages::{
self,
DirectPeerInfoRequest,
DirectPeerInfoResponse,
PeerInfo,
SyncMissingBlocksRequest,
SyncMissingBlocksResponse,
},
peer_store::{AddPeerStatus, PeerStore},
relay_store::RelayStore,
},
Expand All @@ -85,7 +86,6 @@ use crate::{
ShareChain,
},
};
use crate::server::p2p::messages::{DirectPeerInfoRequest, DirectPeerInfoResponse};

const PEER_INFO_TOPIC: &str = "peer_info";
const BLOCK_NOTIFY_TOPIC: &str = "block_notify";
Expand Down Expand Up @@ -933,7 +933,6 @@ where S: ShareChain
error!(target: LOG_TARGET, "Failed to create peer info: {error:?}");
})
{

if let Err(e) = self.swarm.behaviour_mut().meta_data_exchange.send_response(
channel,
Ok(MetaDataResponse {
Expand Down Expand Up @@ -1473,26 +1472,26 @@ where S: ShareChain
request_response::Event::ResponseSent { .. } => {},
},
ServerNetworkBehaviourEvent::DirectPeerExchange(event) => match event {
request_response::Event::Message { peer: _, message } => match message {
request_response::Message::Request {
request_id: _request_id,
request,
channel,
} => {
self.handle_direct_peer_exchange_request(channel, request).await;
request_response::Event::Message { peer: _, message } => match message {
request_response::Message::Request {
request_id: _request_id,
request,
channel,
} => {
self.handle_direct_peer_exchange_request(channel, request).await;
},
request_response::Message::Response {
request_id: _request_id,
response,
} => match response {
Ok(response) => {
self.handle_direct_peer_exchange_response(response).await;
},
request_response::Message::Response {
request_id: _request_id,
response,
} => match response {
Ok(response) => {
self.handle_direct_peer_exchange_response(response).await;
},
Err(error) => {
error!(target: LOG_TARGET, "REQ-RES peer info response error: {error:?}");
},
Err(error) => {
error!(target: LOG_TARGET, "REQ-RES peer info response error: {error:?}");
},
},
},
request_response::Event::OutboundFailure { peer, error, .. } => {
// Peers can be offline
debug!(target: LOG_TARGET, "REQ-RES peer info outbound failure: {peer:?} -> {error:?}");
Expand Down
19 changes: 16 additions & 3 deletions src/server/p2p/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,25 @@ use tokio::{
io::{self, AsyncReadExt, AsyncWriteExt},
};

use super::{messages::{CatchUpSyncRequest, CatchUpSyncResponse, MetaDataRequest, MetaDataResponse}, Config, ServerNetworkBehaviour, CATCH_UP_SYNC_REQUEST_RESPONSE_PROTOCOL, DIRECT_PEER_EXCHANGE_REQ_RESP_PROTOCOL, META_DATA_EXCHANGE_REQ_RESP_PROTOCOL, SHARE_CHAIN_SYNC_REQ_RESP_PROTOCOL, STABLE_PRIVATE_KEY_FILE};
use super::{
messages::{CatchUpSyncRequest, CatchUpSyncResponse, MetaDataRequest, MetaDataResponse},
Config,
ServerNetworkBehaviour,
CATCH_UP_SYNC_REQUEST_RESPONSE_PROTOCOL,
DIRECT_PEER_EXCHANGE_REQ_RESP_PROTOCOL,
META_DATA_EXCHANGE_REQ_RESP_PROTOCOL,
SHARE_CHAIN_SYNC_REQ_RESP_PROTOCOL,
STABLE_PRIVATE_KEY_FILE,
};
use crate::server::{
config,
p2p::messages::{SyncMissingBlocksRequest, SyncMissingBlocksResponse},
p2p::messages::{
DirectPeerInfoRequest,
DirectPeerInfoResponse,
SyncMissingBlocksRequest,
SyncMissingBlocksResponse,
},
};
use crate::server::p2p::messages::{DirectPeerInfoRequest, DirectPeerInfoResponse};

/// Generates or reads libp2p private key if stable_peer is set to true otherwise returns a random key.
/// Using this method we can be sure that our Peer ID remains the same across restarts in case of
Expand Down

0 comments on commit 68b3248

Please sign in to comment.