mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-12-28 17:25:18 +00:00
Add shard config in status messgae
This commit is contained in:
parent
bfe434972d
commit
a37836a91d
@ -399,9 +399,7 @@ mod tests {
|
||||
use std::io::Write;
|
||||
|
||||
fn status_message() -> StatusMessage {
|
||||
StatusMessage {
|
||||
data: Default::default(),
|
||||
}
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn ping_message() -> Ping {
|
||||
@ -570,10 +568,7 @@ mod tests {
|
||||
assert_eq!(stream_identifier.len(), 10);
|
||||
|
||||
// Status message is 84 bytes uncompressed. `max_compressed_len` is 32 + 84 + 84/6 = 130.
|
||||
let status_message_bytes = StatusMessage {
|
||||
data: Default::default(),
|
||||
}
|
||||
.as_ssz_bytes();
|
||||
let status_message_bytes = StatusMessage::default().as_ssz_bytes();
|
||||
|
||||
let mut uvi_codec: Uvi<usize> = Uvi::default();
|
||||
let mut dst = BytesMut::with_capacity(1024);
|
||||
|
@ -69,9 +69,13 @@ impl ToString for ErrorType {
|
||||
/* Requests */
|
||||
|
||||
/// The STATUS request/response handshake message.
|
||||
#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, Default)]
|
||||
pub struct StatusMessage {
|
||||
pub data: NetworkIdentity,
|
||||
|
||||
// shard config
|
||||
pub num_shard: usize,
|
||||
pub shard_id: usize,
|
||||
}
|
||||
|
||||
/// The PING request/response message.
|
||||
|
@ -23,14 +23,10 @@ fn test_status_rpc() {
|
||||
let (mut sender, mut receiver) = common::build_node_pair(Arc::downgrade(&rt)).await;
|
||||
|
||||
// Dummy STATUS RPC message
|
||||
let rpc_request = Request::Status(StatusMessage {
|
||||
data: Default::default(),
|
||||
});
|
||||
let rpc_request = Request::Status(Default::default());
|
||||
|
||||
// Dummy STATUS RPC message
|
||||
let rpc_response = Response::Status(StatusMessage {
|
||||
data: Default::default(),
|
||||
});
|
||||
let rpc_response = Response::Status(Default::default());
|
||||
|
||||
// build the sender future
|
||||
let sender_future = async {
|
||||
|
@ -172,8 +172,11 @@ impl Libp2pEventHandler {
|
||||
}
|
||||
|
||||
pub fn send_status(&self, peer_id: PeerId) {
|
||||
let shard_config = self.store.get_store().get_shard_config();
|
||||
let status_message = StatusMessage {
|
||||
data: self.network_globals.network_id(),
|
||||
num_shard: shard_config.num_shard,
|
||||
shard_id: shard_config.shard_id,
|
||||
};
|
||||
debug!(%peer_id, ?status_message, "Sending Status request");
|
||||
|
||||
@ -254,8 +257,11 @@ impl Libp2pEventHandler {
|
||||
debug!(%peer_id, ?status, "Received Status request");
|
||||
|
||||
let network_id = self.network_globals.network_id();
|
||||
let shard_config = self.store.get_store().get_shard_config();
|
||||
let status_message = StatusMessage {
|
||||
data: network_id.clone(),
|
||||
num_shard: shard_config.num_shard,
|
||||
shard_id: shard_config.shard_id,
|
||||
};
|
||||
debug!(%peer_id, ?status_message, "Sending Status response");
|
||||
|
||||
@ -1216,6 +1222,8 @@ mod tests {
|
||||
let req_id = (ConnectionId::new(4), SubstreamId(12));
|
||||
let request = Request::Status(StatusMessage {
|
||||
data: Default::default(),
|
||||
num_shard: 1,
|
||||
shard_id: 0,
|
||||
});
|
||||
handler.on_rpc_request(alice, req_id, request).await;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user