Skip to content

Commit

Permalink
chore: rename bitswap-transfer example (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel authored Sep 2, 2024
1 parent 08f200a commit 317eb7d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Once you have your example finished, do not forget to run `go mod tidy` and addi

## Examples and Tutorials

- [Fetching a UnixFS file by CID](./unixfs-file-cid)
- [Transfering UnixFS file data with Bitswap](./bitswap-transfer)
- [Gateway backed by a local blockstore in form of a CAR file](./gateway/car-file)
- [Gateway backed by a remote (HTTP) blockstore and IPNS resolver](./gateway/proxy-blocks)
- [Gateway backed by a remote (HTTP) CAR Gateway](./gateway/proxy-car)
Expand Down
1 change: 1 addition & 0 deletions examples/bitswap-transfer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bitswap-transfer
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Downloading a UnixFS file
# Transfering UnixFS file with Bitswap

This is an example that quickly shows how to use IPFS tooling to move around a file.

Expand All @@ -13,26 +13,26 @@ In client mode, it will start up, connect to the server, request the data needed
From the `boxo/examples` directory run the following:

```
> cd unixfs-file-cid/
> cd bitswap-transfer/
> go build
```

## Usage

```
> ./unixfs-file-cid
> ./bitswap-transfer
2023/01/30 21:34:11 I am /ip4/127.0.0.1/tcp/53935/p2p/QmUtp8xEVgWC5dNPthF2g37eVvCdrqY1FPxLxXZoKkPbdp
2023/01/30 21:34:11 hosting UnixFS file with CID: bafybeiecq2irw4fl5vunnxo6cegoutv4de63h7n27tekkjtak3jrvrzzhe
2023/01/30 21:34:11 listening for inbound connections and Bitswap requests
2023/01/30 21:34:11 Now run "./unixfs-file-cid -d /ip4/127.0.0.1/tcp/53935/p2p/QmUtp8xEVgWC5dNPthF2g37eVvCdrqY1FPxLxXZoKkPbdp" on a different terminal
2023/01/30 21:34:11 Now run "./bitswap-transfer -d /ip4/127.0.0.1/tcp/53935/p2p/QmUtp8xEVgWC5dNPthF2g37eVvCdrqY1FPxLxXZoKkPbdp" on a different terminal
```

The IPFS server hosting the data over libp2p will print out its `Multiaddress`, which indicates how it can be reached (ip4+tcp) and its randomly generated ID (`QmUtp8xEV...`)

Now, launch another node that talks to the hosting node:

```
> ./unixfs-file-cid -d /ip4/127.0.0.1/tcp/53935/p2p/QmUtp8xEVgWC5dNPthF2g37eVvCdrqY1FPxLxXZoKkPbdp
> ./bitswap-transfer -d /ip4/127.0.0.1/tcp/53935/p2p/QmUtp8xEVgWC5dNPthF2g37eVvCdrqY1FPxLxXZoKkPbdp
```

The IPFS client will then download the file from the server peer and let you know that it's been received.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
"github.com/ipfs/boxo/files"
)

const exampleBinaryName = "unixfs-file-cid"
const exampleBinaryName = "bitswap-transfer"

func main() {
ctx, cancel := context.WithCancel(context.Background())
Expand Down
File renamed without changes.

0 comments on commit 317eb7d

Please sign in to comment.