Change P2P protocol version

This commit is contained in:
boqiu 2024-10-25 10:53:16 +08:00
parent 0f93b035f1
commit 43afc79a4a
2 changed files with 7 additions and 4 deletions

View File

@ -93,7 +93,10 @@ pub use peer_manager::{
};
pub use service::{load_private_key, Context, Libp2pEvent, Service, NETWORK_KEY_FILENAME};
pub const PROTOCOL_VERSION: [u8; 3] = [0, 1, 0];
/// Defines the current P2P protocol version.
/// - v1: Broadcast FindFile & AnnounceFile messages in the whole network, which caused network too heavey.
/// - v2: Publish NewFile to neighbors only and announce file via RPC message.
pub const PROTOCOL_VERSION: [u8; 3] = [0, 2, 0];
/// Application level requests sent to the network.
#[derive(Debug, Clone, Copy)]

View File

@ -397,6 +397,9 @@ impl Libp2pEventHandler {
Err(_) => return MessageAcceptance::Reject,
};
// update shard config cache
self.file_location_cache.insert_peer_config(from, announced_shard_config);
// ignore if already exists
match self.store.check_tx_completed(msg.tx_id.seq).await {
Ok(true) => return MessageAcceptance::Ignore,
@ -423,9 +426,6 @@ impl Libp2pEventHandler {
self.send_to_sync(SyncMessage::NewFile { from, msg });
}
self.file_location_cache
.insert_peer_config(from, announced_shard_config);
MessageAcceptance::Ignore
}