1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
//! Another libp2p
//! bitswap([SPEC](https://github.com/ipfs/specs/blob/main/BITSWAP.md))
//! implementation in Rust.
//!
//! ## Features
//!
//! - Compatible with [`go-bitswap`](https://github.com/ipfs/go-bitswap)
//! - Optional request manager
//! - Prometheus metrics
//!
//! ## Usage
//!
//! Basic usage of `BitswapBehaviour`, for writing swarm event flow, sending or
//! receiving a request or a response, checkout `tests/go_compat.rs`. Note that a
//! request manager is needed for a real-world application.
//!
//! To use the builtin request manager that is optimized for Filecoin network, a
//! data store that implements `BitswapStoreRead` and `BitswapStoreReadWrite` is
//! required. For hooking request manager in swarm event flow, requesting a block
//! via request manager API, checkout `tests/request_manager.rs`.

use std::io::Result as IOResult;

use libipld::{cid::Cid, prelude::*};
use tracing::*;

mod bitswap_pb;

mod internals;
use internals::*;

mod behaviour;
pub use behaviour::*;

mod message;
pub use message::*;

mod metrics;
pub use metrics::register_metrics;

pub mod request_manager;

mod store;
pub use store::*;

#[cfg(not(target_arch = "wasm32"))]
pub mod task {
    //! Re-exports API(s) from the chosen task library
    pub use tokio::{spawn, task::spawn_blocking, time::sleep};
}
#[cfg(test)]
mod tests {
    mod request_manager;
}