Skip to content

Commit

Permalink
add NetworkRequests::SnapshotHostInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
saketh-are committed Nov 2, 2023
1 parent a7ddcd0 commit 4b6e295
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions chain/client/src/test_utils/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ pub fn setup_mock_all_validators(
NetworkRequests::ForwardTx(_, _)
| NetworkRequests::BanPeer { .. }
| NetworkRequests::TxStatus(_, _, _)
| NetworkRequests::SnapshotHostInfo(_)
| NetworkRequests::Challenge(_) => {}
};
}
Expand Down
3 changes: 1 addition & 2 deletions chain/network/src/network_protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod borsh_conv;
mod edge;
mod peer;
mod proto_conv;
pub mod state_sync;
mod state_sync;
pub use edge::*;
pub use peer::*;
pub use state_sync::*;
Expand All @@ -24,7 +24,6 @@ pub use _proto::network as proto;
use crate::network_protocol::proto_conv::trace_context::{
extract_span_context, inject_trace_context,
};
use crate::network_protocol::state_sync::SyncSnapshotHosts;
use borsh::BorshDeserialize as _;
use near_async::time;
use near_crypto::PublicKey;
Expand Down
3 changes: 1 addition & 2 deletions chain/network/src/peer_manager/connection/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use crate::concurrency::arc_mutex::ArcMutex;
use crate::concurrency::atomic_cell::AtomicCell;
use crate::concurrency::demux;
use crate::network_protocol::state_sync::SyncSnapshotHosts;
use crate::network_protocol::{
PeerInfo, PeerMessage, RoutedMessageBody, SignedAccountData, SignedOwnedAccount,
SnapshotHostInfo, SyncAccountsData,
SnapshotHostInfo, SyncAccountsData, SyncSnapshotHosts,
};
use crate::peer::peer_actor;
use crate::peer::peer_actor::PeerActor;
Expand Down
7 changes: 7 additions & 0 deletions chain/network/src/peer_manager/peer_manager_actor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::client;
use crate::config;
use crate::debug::{DebugStatus, GetDebugStatus};
use crate::network_protocol::SyncSnapshotHosts;
use crate::network_protocol::{
Disconnect, Edge, PeerIdOrHash, PeerMessage, Ping, Pong, RawRoutedMessage, RoutedMessageBody,
};
Expand Down Expand Up @@ -783,6 +784,12 @@ impl PeerManagerActor {
NetworkResponses::RouteNotFound
}
}
NetworkRequests::SnapshotHostInfo(snapshot_host_info) => {
self.state.tier2.broadcast_message(Arc::new(PeerMessage::SyncSnapshotHosts(
SyncSnapshotHosts { hosts: vec![snapshot_host_info] },
)));
NetworkResponses::NoResponse
}
NetworkRequests::BanPeer { peer_id, ban_reason } => {
self.state.disconnect_and_ban(&self.clock, &peer_id, ban_reason);
NetworkResponses::NoResponse
Expand Down
4 changes: 3 additions & 1 deletion chain/network/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub use crate::network_protocol::{
/// Exported types, which are part of network protocol.
pub use crate::network_protocol::{
Edge, PartialEdgeInfo, PartialEncodedChunkForwardMsg, PartialEncodedChunkRequestMsg,
PartialEncodedChunkResponseMsg, PeerChainInfoV2, PeerInfo, StateResponseInfo,
PartialEncodedChunkResponseMsg, PeerChainInfoV2, PeerInfo, SnapshotHostInfo, StateResponseInfo,
StateResponseInfoV1, StateResponseInfoV2,
};
use crate::routing::routing_table_view::RoutingTableInfo;
Expand Down Expand Up @@ -232,6 +232,8 @@ pub enum NetworkRequests {
BanPeer { peer_id: PeerId, ban_reason: ReasonForBan },
/// Announce account
AnnounceAccount(AnnounceAccount),
/// Broadcast information about a hosted snapshot.
SnapshotHostInfo(Arc<SnapshotHostInfo>),

/// Request chunk parts and/or receipts
PartialEncodedChunkRequest {
Expand Down

0 comments on commit 4b6e295

Please sign in to comment.