Skip to content

Commit

Permalink
refactor: Remove external bitswap implementation (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusc93 committed Jun 17, 2024
1 parent 3d567af commit 9b38f75
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 611 deletions.
55 changes: 9 additions & 46 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ description = "IPFS node implementation"
version = "0.11.20"

[features]

default = []

experimental_stream = ["dep:libp2p-stream"]

webrtc_transport = ["dep:libp2p-webrtc"]

beetle_bitswap = ["dep:beetle-bitswap-next"]
libp2p_bitswap = ["dep:libp2p-bitswap-next"]
libp2p_bitswap_compat = ["libp2p_bitswap", "libp2p-bitswap-next?/compat"]

sled_data_store = ["dep:sled"]
redb_data_store = ["dep:redb"]
test_go_interop = []
Expand All @@ -32,7 +27,6 @@ async-stream = { version = "0.3" }
async-trait = { version = "0.1" }
asynchronous-codec = "0.7.0"
base64 = { default-features = false, features = ["alloc"], version = "0.22" }
beetle-bitswap-next = { version = "0.5.1", path = "packages/beetle-bitswap-next" }
byteorder = { version = "1" }
bytes = "1"
chrono = { version = "0.4.35" }
Expand All @@ -50,7 +44,6 @@ indexmap = "2.2.0"
libipld = { version = "0.16", features = ["serde-codec"] }
libp2p = { version = "0.53" }
libp2p-allow-block-list = "0.3"
libp2p-bitswap-next = { version = "0.26.3", path = "packages/libp2p-bitswap-next" }
libp2p-relay-manager = { version = "0.2.4", path = "packages/libp2p-relay-manager" }
libp2p-stream = { version = "0.1.0-alpha.1" }
libp2p-webrtc = { version = "=0.7.1-alpha", features = ["pem"] }
Expand Down Expand Up @@ -100,7 +93,6 @@ async-stream.workspace = true
async-trait.workspace = true
asynchronous-codec.workspace = true
base64 = { workspace = true }
beetle-bitswap-next = { workspace = true, optional = true }
byteorder = { workspace = true }
bytes = { workspace = true }
chrono.workspace = true
Expand All @@ -111,7 +103,6 @@ hkdf.workspace = true
indexmap.workspace = true
libipld.workspace = true
libp2p-allow-block-list.workspace = true
libp2p-bitswap-next = { workspace = true, optional = true }
libp2p-relay-manager = { workspace = true }
libp2p-stream = { workspace = true, optional = true }
p256.workspace = true
Expand All @@ -138,7 +129,6 @@ zeroize.workspace = true

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
futures-timer.workspace = true
beetle-bitswap-next = { workspace = true, optional = true }
fs2.workspace = true
hickory-resolver.workspace = true
libp2p = { features = ["gossipsub", "autonat", "relay", "dcutr", "identify", "kad", "websocket", "tcp", "macros", "tokio", "noise", "tls", "ping", "yamux", "dns", "mdns", "ed25519", "secp256k1", "ecdsa", "rsa", "serde", "request-response", "json", "cbor", "rendezvous", "upnp", "quic", ], workspace = true }
Expand Down
48 changes: 0 additions & 48 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ use futures::{

use keystore::Keystore;

#[cfg(feature = "beetle_bitswap")]
use p2p::BitswapConfig;

use p2p::{
IdentifyConfiguration, KadConfig, KadStoreConfig, MultiaddrExt, PeerInfo, PubsubConfig,
RelayConfig, SwarmConfig, TransportConfig,
Expand Down Expand Up @@ -189,10 +186,6 @@ pub struct IpfsOptions {
/// Nodes used as bootstrap peers.
pub bootstrap: Vec<Multiaddr>,

#[cfg(feature = "beetle_bitswap")]
/// Bitswap configuration
pub bitswap_config: BitswapConfig,

/// Relay server config
pub relay_server_config: RelayConfig,

Expand Down Expand Up @@ -284,8 +277,6 @@ impl Default for IpfsOptions {
Self {
ipfs_path: StorageType::Memory,
bootstrap: Default::default(),
#[cfg(feature = "beetle_bitswap")]
bitswap_config: Default::default(),
relay_server_config: Default::default(),
kad_configuration: Either::Left(Default::default()),
kad_store_config: Default::default(),
Expand Down Expand Up @@ -599,29 +590,6 @@ impl<C: NetworkBehaviour<ToSwarm = void::Void> + Send> UninitializedIpfs<C> {
self
}

#[cfg(feature = "beetle_bitswap")]
/// Load default behaviour for basic functionality
pub fn with_default(self) -> Self {
self.with_identify(Default::default())
.with_autonat()
.with_bitswap(Default::default())
.with_kademlia(Either::Left(Default::default()), Default::default())
.with_ping(Default::default())
.with_pubsub(Default::default())
}

#[cfg(feature = "libp2p_bitswap")]
/// Load default behaviour for basic functionality
pub fn with_default(self) -> Self {
self.with_identify(Default::default())
.with_autonat()
.with_bitswap()
.with_kademlia(Either::Left(Default::default()), Default::default())
.with_ping(Default::default())
.with_pubsub(Default::default())
}

#[cfg(not(any(feature = "libp2p_bitswap", feature = "beetle_bitswap")))]
/// Load default behaviour for basic functionality
pub fn with_default(self) -> Self {
self.with_identify(Default::default())
Expand All @@ -645,22 +613,6 @@ impl<C: NetworkBehaviour<ToSwarm = void::Void> + Send> UninitializedIpfs<C> {
self
}

#[cfg(feature = "beetle_bitswap")]
/// Enables bitswap
pub fn with_bitswap(mut self, config: BitswapConfig) -> Self {
self.options.protocols.bitswap = true;
self.options.bitswap_config = config;
self
}

#[cfg(feature = "libp2p_bitswap")]
/// Enables bitswap
pub fn with_bitswap(mut self) -> Self {
self.options.protocols.bitswap = true;
self
}

#[cfg(not(any(feature = "libp2p_bitswap", feature = "beetle_bitswap")))]
/// Enables bitswap
pub fn with_bitswap(mut self) -> Self {
self.options.protocols.bitswap = true;
Expand Down
Loading

0 comments on commit 9b38f75

Please sign in to comment.