2020-04-30 06:57:49 +00:00
|
|
|
# Table of Contents
|
|
|
|
- [Introduction](#introduction)
|
2024-02-15 15:14:26 +00:00
|
|
|
- [Prerequisites](#prerequisites)
|
2020-04-30 06:57:49 +00:00
|
|
|
- [Installation](#installation)
|
2024-02-15 15:14:26 +00:00
|
|
|
- [Script](#script)
|
2020-04-30 06:57:49 +00:00
|
|
|
- [Usage](#usage)
|
|
|
|
- [Example](#example)
|
|
|
|
- [Getting Started](#getting-started)
|
|
|
|
|
|
|
|
# Introduction
|
|
|
|
This is a libp2p-backed daemon wrapping the functionalities of go-libp2p for use in Nim. <br>
|
|
|
|
For more information about the go daemon, check out [this repository](https://github.com/libp2p/go-libp2p-daemon).
|
2024-02-15 15:14:26 +00:00
|
|
|
> **Required only** for running the tests.
|
|
|
|
|
|
|
|
# Prerequisites
|
|
|
|
Go with version `1.15.15`.
|
|
|
|
> You will *likely* be able to build `go-libp2p-daemon` with different Go versions, but **they haven't been tested**.
|
2020-04-30 06:57:49 +00:00
|
|
|
|
|
|
|
# Installation
|
2024-02-15 15:14:26 +00:00
|
|
|
Follow one of the methods below:
|
|
|
|
|
|
|
|
## Script
|
|
|
|
Run the build script while having the `go` command pointing to the correct Go version.
|
|
|
|
We recommend using `1.15.15`, as previously stated.
|
|
|
|
```sh
|
|
|
|
./scripts/build_p2pd.sh
|
|
|
|
```
|
|
|
|
If everything goes correctly, the binary (`p2pd`) should be built and placed in the correct directory.
|
|
|
|
If you find any issues, please head into our discord and ask for our asistance.
|
|
|
|
|
|
|
|
After successfully building the binary, remember to add it to your path so it can be found. You can do that by running:
|
2020-04-30 06:57:49 +00:00
|
|
|
```sh
|
2024-02-15 15:14:26 +00:00
|
|
|
export PATH="$PATH:$HOME/go/bin"
|
2020-04-30 06:57:49 +00:00
|
|
|
```
|
2024-02-15 15:14:26 +00:00
|
|
|
> **Tip:** To make this change permanent, add the command above to your `.bashrc` file.
|
2020-04-30 06:57:49 +00:00
|
|
|
|
|
|
|
# Usage
|
|
|
|
|
|
|
|
## Example
|
|
|
|
Examples can be found in the [examples folder](https://github.com/status-im/nim-libp2p/tree/readme/examples/go-daemon)
|
|
|
|
|
|
|
|
## Getting Started
|
|
|
|
Try out the chat example. Full code can be found [here](https://github.com/status-im/nim-libp2p/blob/master/examples/chat.nim):
|
|
|
|
|
|
|
|
```bash
|
2021-06-28 04:36:57 +00:00
|
|
|
nim c -r --threads:on examples/directchat.nim
|
2020-04-30 06:57:49 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
This will output a peer ID such as `QmbmHfVvouKammmQDJck4hz33WvVktNEe7pasxz2HgseRu` which you can use in another instance to connect to it.
|
|
|
|
|
|
|
|
```bash
|
2021-06-28 04:36:57 +00:00
|
|
|
./examples/directchat
|
2020-04-30 06:57:49 +00:00
|
|
|
/connect QmbmHfVvouKammmQDJck4hz33WvVktNEe7pasxz2HgseRu
|
|
|
|
```
|
|
|
|
|
|
|
|
You can now chat between the instances!
|
|
|
|
|
|
|
|
![Chat example](https://imgur.com/caYRu8K.gif)
|
|
|
|
|
|
|
|
|
|
|
|
|