This repository has been archived by the owner on Oct 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 164
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
David Craven
committed
Mar 13, 2020
1 parent
d755576
commit 1428034
Showing
28 changed files
with
554 additions
and
630 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "bitswap" | ||
version = "0.1.0" | ||
authors = ["David Craven <[email protected]>"] | ||
edition = "2018" | ||
|
||
[build-dependencies] | ||
prost-build = "0.6.1" | ||
|
||
[dependencies] | ||
anyhow = "1.0.26" | ||
async-std = "1.5.0" | ||
async-trait = "0.1.24" | ||
fnv = "1.0.6" | ||
futures = "0.3.4" | ||
libipld = "0.1.0" | ||
libp2p-core = "0.16.0" | ||
libp2p-swarm = "0.16.1" | ||
log = "0.4.8" | ||
prost = "0.6.1" | ||
thiserror = "1.0.11" |
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,3 @@ | ||
fn main() { | ||
prost_build::compile_protos(&["src/bitswap_pb.proto"], &["src"]).unwrap(); | ||
} |
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
File renamed without changes.
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,21 @@ | ||
use libipld::cid::Cid; | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq)] | ||
pub struct Block { | ||
pub cid: Cid, | ||
pub data: Box<[u8]>, | ||
} | ||
|
||
impl Block { | ||
pub fn new(data: Box<[u8]>, cid: Cid) -> Self { | ||
Self { cid, data } | ||
} | ||
|
||
pub fn cid(&self) -> &Cid { | ||
&self.cid | ||
} | ||
|
||
pub fn data(&self) -> &[u8] { | ||
&self.data | ||
} | ||
} |
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,11 @@ | ||
use thiserror::Error; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum BitswapError { | ||
#[error("Error while reading from socket: {0}")] | ||
ReadError(#[from] libp2p_core::upgrade::ReadOneError), | ||
#[error("Error while decoding bitswap message: {0}")] | ||
ProtobufError(#[from] prost::DecodeError), | ||
#[error("Error while parsing cid: {0}")] | ||
Cid(#[from] libipld::cid::Error), | ||
} |
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
Oops, something went wrong.