Skip to content

Commit

Permalink
Merge pull request #26 from algorealmInc/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
thewoodfish authored May 1, 2024
2 parents 5394d03 + cc56a4e commit 17d178e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
3 changes: 3 additions & 0 deletions swarm_nl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 9 additions & 0 deletions swarm_nl/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions swarm_nl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
10 changes: 2 additions & 8 deletions swarm_nl/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,10 @@ pub enum AppData {
KademliaDeleteRecord { key: Vec<u8> },
/// Return important information about the local routing table
KademliaGetRoutingTableInfo,
/// Fetch data(s) quickly from a peer over the network
FetchData { keys: Vec<Vec<u8>>, 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 {
Expand Down
4 changes: 3 additions & 1 deletion swarm_nl/src/setup.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit 17d178e

Please sign in to comment.