GraphSync
Rust implementation of the GraphSync v2 wire protocol.
Background
GraphSync is an IPFS data transfer protocol used across the IPFS and Web3 ecosystem for exchanging IPLD data. It is used by Filecoin for syncing the blockchain and transfering DAGified content in a trustless fashion.
Usage
To add this crate to your repo, either add graphsync
to your Cargo.toml
or run cargo add graphsync
.
You might also need selectors from ipld_traversal
crate.
use ;
use MemoryBlockstore;
use ;
// See Libp2p examples for more info on transports.
let = gen_transport;
let store = new;
let mut swarm = new;
let client = swarm.behaviour_mut;
let mut maddr: Multiaddr = "/ip4/127.0.0.1/tcp/53870/p2p/12D3KooWC2E2mnp5x3CfJG4n9vFXabTwSrc2PfbNWzSZhCjCN3rr".parse.unwrap;
if let Some = maddr.pop
Benchmarks
To benchmark IPLD traversals for different tree sizes run
To benchmark end to end transfers run
Examples
-
Data Transfer Demonstrate how to integrate GraphSync in a larger app or into a wrapper protocol using the Filecoin data transfer protocol. See the main.rs file for info on how to run.
-
WASM Demonstrate how to integrate GraphSync into a WASM module.