Skip to content

Commit

Permalink
small p2p rfk, permissive to None tmprarily
Browse files Browse the repository at this point in the history
  • Loading branch information
erhant committed Sep 4, 2024
1 parent 1bc02fb commit 1154dd7
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/p2p/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 6 additions & 9 deletions src/p2p/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::p2p::AvailableNodes;
use libp2p::futures::StreamExt;
use libp2p::gossipsub::{
Message, MessageAcceptance, MessageId, PublishError, SubscriptionError, TopicHash,
Expand All @@ -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};

Expand Down Expand Up @@ -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
Expand All @@ -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::<Vec<_>>()
self.swarm.behaviour().gossipsub.all_peers().collect()
}

/// Listens to the Swarm for incoming messages.
Expand Down
3 changes: 0 additions & 3 deletions src/p2p/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,4 @@ mod message;

pub use message::P2PMessage;

mod available_nodes;
pub use available_nodes::AvailableNodes;

mod data_transform;
File renamed without changes.
3 changes: 3 additions & 0 deletions src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 1154dd7

Please sign in to comment.