diff --git a/src/node.rs b/src/node.rs index 20d7f66..70020a8 100644 --- a/src/node.rs +++ b/src/node.rs @@ -6,8 +6,8 @@ use crate::{ config::DriaComputeNodeConfig, errors::NodeResult, handlers::{ComputeHandler, PingpongHandler, WorkflowHandler}, - p2p::{AvailableNodes, P2PClient, P2PMessage}, - utils::crypto::secret_to_keypair, + p2p::{P2PClient, P2PMessage}, + utils::{crypto::secret_to_keypair, AvailableNodes}, }; /// Number of seconds between refreshing the Admin RPC PeerIDs from Dria server. diff --git a/src/p2p/behaviour.rs b/src/p2p/behaviour.rs index e5f04c8..c578002 100644 --- a/src/p2p/behaviour.rs +++ b/src/p2p/behaviour.rs @@ -96,7 +96,7 @@ fn create_gossipsub_behavior(author: PeerId) -> gossipsub::Behaviour { /// We accept permissive validation mode, meaning that we accept all messages /// and check their fields based on whether they exist or not. - const VALIDATION_MODE: ValidationMode = ValidationMode::Permissive; + const VALIDATION_MODE: ValidationMode = ValidationMode::None; // FIXME: change this to Permissive /// Heartbeat interval in seconds const HEARTBEAT_INTERVAL_SECS: u64 = 10; diff --git a/src/p2p/client.rs b/src/p2p/client.rs index 5c74b8f..68ec46f 100644 --- a/src/p2p/client.rs +++ b/src/p2p/client.rs @@ -1,4 +1,3 @@ -use crate::p2p::AvailableNodes; use libp2p::futures::StreamExt; use libp2p::gossipsub::{ Message, MessageAcceptance, MessageId, PublishError, SubscriptionError, TopicHash, @@ -9,8 +8,10 @@ use libp2p::{ }; use libp2p::{Multiaddr, PeerId, Swarm, SwarmBuilder}; use libp2p_identity::Keypair; -use tokio::time::Duration; -use tokio::time::Instant; +use std::time::Duration; +use std::time::Instant; + +use crate::utils::AvailableNodes; use super::{DriaBehaviour, DriaBehaviourEvent, P2P_KADEMLIA_PROTOCOL, P2P_PROTOCOL_STRING}; @@ -168,7 +169,7 @@ impl P2PClient { propagation_source: &PeerId, acceptance: MessageAcceptance, ) -> Result<(), PublishError> { - log::debug!("Validating message ({}): {:?}", msg_id, acceptance); + log::trace!("Validating message ({}): {:?}", msg_id, acceptance); let msg_was_in_cache = self .swarm @@ -184,11 +185,7 @@ impl P2PClient { /// Returns the list of connected peers within Gossipsub, with a list of subscribed topic hashes by each peer. pub fn peers(&self) -> Vec<(&PeerId, Vec<&TopicHash>)> { - self.swarm - .behaviour() - .gossipsub - .all_peers() - .collect::>() + self.swarm.behaviour().gossipsub.all_peers().collect() } /// Listens to the Swarm for incoming messages. diff --git a/src/p2p/mod.rs b/src/p2p/mod.rs index 023f770..960afd5 100644 --- a/src/p2p/mod.rs +++ b/src/p2p/mod.rs @@ -41,7 +41,4 @@ mod message; pub use message::P2PMessage; -mod available_nodes; -pub use available_nodes::AvailableNodes; - mod data_transform; diff --git a/src/p2p/available_nodes.rs b/src/utils/available_nodes.rs similarity index 100% rename from src/p2p/available_nodes.rs rename to src/utils/available_nodes.rs diff --git a/src/utils/mod.rs b/src/utils/mod.rs index f696770..c72209f 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -2,6 +2,9 @@ pub mod crypto; pub mod filter; pub mod payload; +mod available_nodes; +pub use available_nodes::AvailableNodes; + use std::time::{Duration, SystemTime}; /// Returns the current time in nanoseconds since the Unix epoch.