mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-02 21:43:11 +00:00
116 lines
4.2 KiB
Markdown
116 lines
4.2 KiB
Markdown
# Codex Decentralized Durability Engine
|
|
|
|
> The Codex project aims to create a decentralized durability engine that allows persisting data in p2p networks. In other words, it allows storing files and data with predictable durability guarantees for later retrieval.
|
|
|
|
> WARNING: This project is under active development and is considered pre-alpha.
|
|
|
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
[](https://opensource.org/licenses/MIT)
|
|
[](#stability)
|
|
[](https://github.com/codex-storage/nim-codex/actions/workflows/ci.yml?query=branch%3Amaster)
|
|
[](https://github.com/codex-storage/nim-codex/actions/workflows/docker.yml?query=branch%3Amaster)
|
|
[](https://codecov.io/gh/codex-storage/nim-codex)
|
|
[](https://discord.gg/CaJTh24ddQ)
|
|

|
|
|
|
|
|
## Build and Run
|
|
|
|
For detailed instructions on preparing to build nim-codex see [*Build Codex*](https://docs.codex.storage/learn/build).
|
|
|
|
To build the project, clone it and run:
|
|
|
|
```bash
|
|
make update && make
|
|
```
|
|
|
|
The executable will be placed under the `build` directory under the project root.
|
|
|
|
Run the client with:
|
|
|
|
```bash
|
|
build/codex
|
|
```
|
|
|
|
## Configuration
|
|
|
|
It is possible to configure a Codex node in several ways:
|
|
1. CLI options
|
|
2. Environment variables
|
|
3. Configuration file
|
|
|
|
The order of priority is the same as above: CLI options --> Environment variables --> Configuration file.
|
|
|
|
Please check [documentation](https://docs.codex.storage/learn/run#configuration) for more information.
|
|
|
|
## Guides
|
|
|
|
To get acquainted with Codex, consider:
|
|
* running the simple [Codex Two-Client Test](https://docs.codex.storage/learn/local-two-client-test) for a start, and;
|
|
* if you are feeling more adventurous, try [Running a Local Codex Network with Marketplace Support](https://docs.codex.storage/learn/local-marketplace) using a local blockchain as well.
|
|
|
|
## API
|
|
|
|
The client exposes a REST API that can be used to interact with the clients. Overview of the API can be found on [api.codex.storage](https://api.codex.storage).
|
|
|
|
## Bindings
|
|
|
|
Codex provides a C API that can be wrapped by other languages. The bindings is located in the `library` folder.
|
|
Currently, only a Go binding is included.
|
|
|
|
### Build the C library
|
|
|
|
```bash
|
|
make libcodex
|
|
```
|
|
|
|
This produces the shared library under `build/`.
|
|
|
|
### Run the Go example
|
|
|
|
Build the Go example:
|
|
|
|
```bash
|
|
go build -o codex-go examples/golang/codex.go
|
|
```
|
|
|
|
Export the library path:
|
|
|
|
```bash
|
|
export LD_LIBRARY_PATH=build
|
|
```
|
|
|
|
Run the example:
|
|
|
|
```bash
|
|
./codex-go
|
|
```
|
|
|
|
### Static vs Dynamic build
|
|
|
|
By default, Codex builds a dynamic library (`libcodex.so`), which you can load at runtime.
|
|
If you prefer a static library (`libcodex.a`), set the `STATIC` flag:
|
|
|
|
```bash
|
|
# Build dynamic (default)
|
|
make libcodex
|
|
|
|
# Build static
|
|
make STATIC=1 libcodex
|
|
```
|
|
|
|
### Limitation
|
|
|
|
Callbacks must be fast and non-blocking; otherwise, the working thread will hang and prevent other requests from being processed.
|
|
|
|
## Contributing and development
|
|
|
|
Feel free to dive in, contributions are welcomed! Open an issue or submit PRs.
|
|
|
|
### Linting and formatting
|
|
|
|
`nim-codex` uses [nph](https://github.com/arnetheduck/nph) for formatting our code and it is required to adhere to its styling.
|
|
If you are setting up fresh setup, in order to get `nph` run `make build-nph`.
|
|
In order to format files run `make nph/<file/folder you want to format>`.
|
|
If you want you can install Git pre-commit hook using `make install-nph-commit`, which will format modified files prior committing them.
|
|
If you are using VSCode and the [NimLang](https://marketplace.visualstudio.com/items?itemName=NimLang.nimlang) extension you can enable "Format On Save" (eq. the `nim.formatOnSave` property) that will format the files using `nph`. |