Mothra was created to house bindings between Rust-LibP2P and any number of other languages. The languages that are supported (so far) are:
- C
- Java
- .Net
- Rust (duh)
Mothra providea a simple (slightly opinionated) API that requires no previous knowledge of libP2P. The API consists of:
- Basic network configuration settings
- ip addresses
- ports
- logging
- etc
- GossipSub
- RPC
- Discv5
Rust:
Install rustup so you can switch between Rust versions:
> brew install rustup
Install the Rust compiler and package manager:
> rustup-init
DotNet:
Install dotnet sdk here
Once the dotnet sdk is installed open a new Terminal and type:
> dotnet
Usage: dotnet [options]
Usage: dotnet [path-to-application]
Options:
-h|--help Display help.
--info Display .NET Core information.
--list-sdks Display the installed SDKs.
--list-runtimes Display the installed runtimes.
path-to-application:
The path to an application .dll file to execute.
Note: if you receive an error message make sure you are working from a new Terminal session
tmux
(optional):
Installing this will make running the demo easier:
> brew install tmux
On Windows:
Follow the instructions to install rust-up on Windows.
You will need Visual Studio installed; the linker is used by Rust, and the compiler for the C-bindings and example, and dotnet core for the dotnet example.
You will also need vcpkg installed in a sibling folder of Mothra. Clone it from 'https://github.com/microsoft/vcpkg' and then run the bootstrap to configure.
Then use it to install the OpenSSL libraries:
vcpkg install openssl:x64-windows
Building is easy. First, clone the repo:
> git clone https://github.com/prrkl/mothra.git
Next cd into the project's root dir
Debug:
> make rust
Release:
> make rls=1 rust
Next cd into the project's root dir and build:
> make c
Next cd into the project's root dir and build:
> make java
Next cd into the project's root dir and build:
> make dotnet
Use the debug-{VAR_NAME}
option to inspect the value of variables set in config.mk
.
For example, to inspect the value of the OS_LFLAGS
var:
> make debug-OS_LFLAGS
OS_LFLAGS=-mmacosx-version-min=10.15.4 -framework CoreFoundation -framework Security
Run the build scripts a in Visual Studio x64 Native Tools Command Prompt.
A set of batch files, conveniently called Make.cmd, are provided for running on Windows.
> Make.cmd
This will make the C example and dotnet example. (It's not a make file, so no separate targets, just a batch file.)
There is no tmux, but there is a PeerDemo.cmd batch file in the dotnet example which will launch and run two dotnet sessions.
You can also grab the ENR and run a demo between C and dotnet.
Here is a screenshot of the sample app in action:
The sample app demonstrates two clients using Disv5 to find each other and the use of GossipSub to send messages back and forth.
If you have tmux
installed, it is a little simpler to run:
> cd examples/rust && sh peerDemo.sh
The sample app demonstrates two clients using Disv5 to find each other and the use of GossipSub to send messages back and forth.
If you have tmux
installed, it is a little simpler to run:
> cd examples/c && sh peerDemo.sh
The sample app demonstrates two clients using Disv5 to find each other and the use of GossipSub to send messages back and forth.
If you have tmux
installed, it is a little simpler to run:
> cd examples/java && sh peerDemo.sh
The sample app demonstrates two clients using Disv5 to find each other and the use of GossipSub to send messages back and forth.
If you have tmux
installed, it is a little simpler to run:
> cd examples/dotnet && sh peerDemo.sh
-
A big thanks to the Lighthouse crew. Not only does Mothra shamelessly borrow from their project, but I literally learned Rust by looking at their code.
-
Since Mothra is essentially a wrapper around Rust-LibP2P, they deserve a fist bump too.≠≠≠