varroa
is an experimental Nim library for accessing data on the Swarm network using its native libp2p protocols.
The library is the outcome of a weekend experiment meaning it's incomplete, poorly maintained and likely out of date (swarm keeps breaking the protocol), but could be used for further experimentation and tests - patches welcome!
At the time of writing, the library was able to:
- maintain connections with other swarm nodes
- request, cache and serve chunks
- interpret manifests and download files
- expose a simple REST API to access the above functionality
Of course, being a weekend project, the library cuts a few corners:
- no accounting / incentives maintenance whatsoever - we leech from the fee tier that swarm nodes offer
- no database - chunks are stored in files and that's it
- most functionality that upstream bee client missing
- out of date (stop breaking that protocol!)
On the bright side, the code showcases how simple it is to write a Nim libp2p application that talks to a web3 API and exposes a REST server to serve swarm data.
The code shows much similarity with the upstream bee client - the implementation was more or less reverse engineered from there (no protocol spec available at the time of writing the code).
To get an introduction to the concepts of swarm, I'd recommend The book of Swarm.
To get started with the library, download and install the latest pre-release version of nimble.
# Download and extract `nimble` to current folder
curl -L https://github.com/nim-lang/nimble/releases/download/latest/nimble-linux_x64.tar.gz | tar xz
# Make nimble available in the PATH of the current shell
export PATH=$PWD:$PATH
# Clone the git repository
git clone https://github.com/arnetheduck/varroa.git
cd varroa
With nimble
in your PATH
, after cloning the repo:
# Install a local copy of `nim`
nimble install -l -y [email protected]
# Setup all dependencies - skip this step if you go for the `develop` mode below
nimble setup -l
This above commands will install nim
and all project dependencies in the nimbledeps
folder.
Alternatively, to enable full development mode which instead clones all dependencies with git
into vendor
, run:
# Install all dependencies in the vendor folder.
./develop.sh
Once you have the dependencies set up, you can build the project with:
nimble build
bin/varroa
The hackers and dreamers of swarm remind me that there is still hope for cyberspace...