mirror of
				https://github.com/0glabs/0g-storage-node.git
				synced 2025-11-04 08:37:27 +00:00 
			
		
		
		
	Fix protocol version issue (#277)
This commit is contained in:
		
							parent
							
								
									cfe05b6f00
								
							
						
					
					
						commit
						2a24bbde18
					
				@ -96,7 +96,8 @@ pub use service::{load_private_key, Context, Libp2pEvent, Service, NETWORK_KEY_F
 | 
			
		||||
/// 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];
 | 
			
		||||
pub const PROTOCOL_VERSION_V1: [u8; 3] = [0, 1, 0];
 | 
			
		||||
pub const PROTOCOL_VERSION_V2: [u8; 3] = [0, 2, 0];
 | 
			
		||||
 | 
			
		||||
/// Application level requests sent to the network.
 | 
			
		||||
#[derive(Debug, Clone, Copy)]
 | 
			
		||||
 | 
			
		||||
@ -39,13 +39,18 @@ impl ZgsConfig {
 | 
			
		||||
            .await
 | 
			
		||||
            .map_err(|e| format!("Unable to get chain id: {:?}", e))?
 | 
			
		||||
            .as_u64();
 | 
			
		||||
        let network_protocol_version = if self.sync.neighbors_only {
 | 
			
		||||
            network::PROTOCOL_VERSION_V2
 | 
			
		||||
        } else {
 | 
			
		||||
            network::PROTOCOL_VERSION_V1
 | 
			
		||||
        };
 | 
			
		||||
        let local_network_id = NetworkIdentity {
 | 
			
		||||
            chain_id,
 | 
			
		||||
            flow_address,
 | 
			
		||||
            p2p_protocol_version: ProtocolVersion {
 | 
			
		||||
                major: network::PROTOCOL_VERSION[0],
 | 
			
		||||
                minor: network::PROTOCOL_VERSION[1],
 | 
			
		||||
                build: network::PROTOCOL_VERSION[2],
 | 
			
		||||
                major: network_protocol_version[0],
 | 
			
		||||
                minor: network_protocol_version[1],
 | 
			
		||||
                build: network_protocol_version[2],
 | 
			
		||||
            },
 | 
			
		||||
        };
 | 
			
		||||
        network_config.network_id = local_network_id.clone();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user