-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
108 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
{ | ||
"rust-analyzer.showUnlinkedFileNotification": false, | ||
"cSpell.words": [ | ||
"bitflags", | ||
"hasher", | ||
"Kadex", | ||
"omni", | ||
"Upnp" | ||
] | ||
"rust-analyzer.showUnlinkedFileNotification": false, | ||
"cSpell.words": [ | ||
"addrs", | ||
"bitflags", | ||
"Cbor", | ||
"hasher", | ||
"Kadex", | ||
"kadx", | ||
"omni", | ||
"reqwest", | ||
"Upnp" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
mod node_profile; | ||
mod omni_address; | ||
mod omni_signature; | ||
|
||
pub use node_profile::*; | ||
pub use omni_address::*; | ||
pub use omni_signature::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | ||
pub struct NodeProfile { | ||
addrs: Vec<String>, | ||
} | ||
|
||
impl fmt::Display for NodeProfile { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "{}", self.addrs.join(", ")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod connection; | ||
pub mod dht; | ||
pub mod exchange; | ||
pub mod session; | ||
pub mod storage; | ||
pub mod util; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mod file; | ||
mod message; | ||
mod node; | ||
|
||
pub use file::*; | ||
pub use message::*; | ||
pub use node::*; |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod initial_node_fetcher; | ||
mod node_exchanger; | ||
|
||
pub use initial_node_fetcher::*; | ||
pub use node_exchanger::*; |
23 changes: 23 additions & 0 deletions
23
modules/engine/src/service/exchange/node/initial_node_fetcher.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use crate::model::NodeProfile; | ||
use reqwest; | ||
|
||
pub struct InitialNodeFetcher { | ||
urls: Vec<String>, | ||
} | ||
|
||
impl InitialNodeFetcher { | ||
pub fn new(urls: [&str]) { | ||
Self { urls: urls.to_vec() } | ||
} | ||
|
||
pub async fn fetch(&self) -> Vec<NodeProfile> { | ||
let client = reqwest::Client::new(); | ||
|
||
for u in self.urls { | ||
let res = client.get(u).send().await?; | ||
let res = res.text().await?; | ||
|
||
for line in res.split_whitespace() {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pub struct NodeExchanger; | ||
|
||
impl NodeExchanger { | ||
pub async fn new() -> Self { | ||
Self {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod cbor; | ||
mod kadx; | ||
|
||
pub use cbor::*; | ||
pub use kadx::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use serde::{de::DeserializeOwned, Serialize}; | ||
use tokio_util::bytes::{Buf, BufMut, Bytes, BytesMut}; | ||
|
||
pub struct Cbor; | ||
|
||
impl Cbor { | ||
pub fn serialize<T: Serialize>(item: T) -> anyhow::Result<Bytes> { | ||
let buffer = BytesMut::new(); | ||
let mut writer = buffer.writer(); | ||
ciborium::ser::into_writer(&item, &mut writer)?; | ||
let buffer = writer.into_inner().freeze(); | ||
Ok(buffer) | ||
} | ||
|
||
pub fn deserialize<T: DeserializeOwned>(b: Bytes) -> anyhow::Result<T> { | ||
let mut reader = b.reader(); | ||
let item = ciborium::de::from_reader(&mut reader)?; | ||
Ok(item) | ||
} | ||
} |
File renamed without changes.