diff --git a/swarm_nl/Cargo.toml b/swarm_nl/Cargo.toml index 98fd0cce..df91afb7 100644 --- a/swarm_nl/Cargo.toml +++ b/swarm_nl/Cargo.toml @@ -12,6 +12,9 @@ rand = "0.8.5" libp2p = { version="0.53.2", "features"=["ping", "tokio", "async-std", "macros", "ping", "async-std", "tokio", "tcp", "noise", "yamux", "quic", "tls", "dns", "kad", "identify"] } libp2p-identity = { version="0.2.8", "features"=["secp256k1", "ecdsa", "rsa", "ed25519"] } futures = "0.3.30" +futures-timer = "3.0.3" +void = "1.0.2" +tracing = "0.1.40" [dependencies.async-std] version = "1.12.0" diff --git a/swarm_nl/src/core.rs b/swarm_nl/src/core.rs index 4c062492..bf67886f 100644 --- a/swarm_nl/src/core.rs +++ b/swarm_nl/src/core.rs @@ -611,6 +611,15 @@ impl Core { AppData::KademliaGetRoutingTableInfo => { // send information let _ = sender.send(StreamData::Network(NetworkData::KademliaDhtInfo { protocol_id: network_info.id.to_string() })).await; + }, + // Fetch data quickly from a peer over the network + AppData::FetchData { keys, peer } => { + // inform the swarm to make the request + if let Ok(peer_id) = PeerId::from_bytes(peer.as_bytes()) { + // let _ = swarm.behaviour_mut().fetch.request_data(key, peer_id); + } else { + + } } } } diff --git a/swarm_nl/src/lib.rs b/swarm_nl/src/lib.rs index 7c9a6dbd..3a08d2bd 100644 --- a/swarm_nl/src/lib.rs +++ b/swarm_nl/src/lib.rs @@ -15,6 +15,6 @@ pub use libp2p::{ pub use libp2p_identity::{rsa::Keypair as RsaKeypair, KeyType, Keypair, PeerId}; mod prelude; -mod util; -mod setup; -mod core; +pub mod util; +pub mod setup; +pub mod core; diff --git a/swarm_nl/src/prelude.rs b/swarm_nl/src/prelude.rs index 74dabdf4..eaf884a5 100644 --- a/swarm_nl/src/prelude.rs +++ b/swarm_nl/src/prelude.rs @@ -126,16 +126,10 @@ pub enum AppData { KademliaDeleteRecord { key: Vec }, /// Return important information about the local routing table KademliaGetRoutingTableInfo, + /// Fetch data(s) quickly from a peer over the network + FetchData { keys: Vec>, peer: PeerIdString }, } -/// I have a file (i'm a provider) -/// I want to store this file on the dht or send it to a specific node (replication) (important when -/// get requests come in and how to respond to it e,g check the filesystem) -/// I want a list of people with this file -/// I need this specific file from a person or everyone -// I need info -// I dont longer have this file (delete fron hashtable) - /// Data sent from the networking layer to the application layer or to itself #[derive(Debug)] pub(crate) enum NetworkData { diff --git a/swarm_nl/src/setup.rs b/swarm_nl/src/setup.rs index cab4b5a8..7abc5695 100644 --- a/swarm_nl/src/setup.rs +++ b/swarm_nl/src/setup.rs @@ -1,4 +1,6 @@ -/// The module containing the data structures and functions to setup a node identity and +/// Copyright (c) 2024 Algorealm + +// The module containing the data structures and functions to setup a node identity and /// configure it for networking. /// /// This file is part of the SwarmNl library.