The Logos Storage project aims to create a filesharing client that allows sharing data privately in p2p networks.
WARNING: This project is under active development and is considered pre-alpha.
The build needs Nim 2.2.14 or later, which ships Nimble 0.26.
To build the project, clone it and run:
make update && make
# To update the dependencies: edit storage.nimble, then
# nimble lock && make updateThe executable will be placed under the build directory under the project root.
Run the client with:
build/storageIt is possible to configure a Logos Storage node in several ways:
- CLI options
- Environment variables
- Configuration file
The order of priority is the same as above: CLI options --> Environment variables --> Configuration file.
Please check build/storage --help for more information.
The node exposes an HTTP API for testing and debugging only. It is not a public API: applications use the C library, see Bindings.
The OpenAPI spec is in openapi.yaml.
Logos Storage provides a C API that can be wrapped by other languages. The C API bindings are located in the library folder.
Currently, only Go bindings are provided in this repo. However, Rust bindings for Logos Storage can be found at https://github.com/nipsysdev/storage-rust-bindings.
make libstorageThis produces the shared library under build/.
See https://github.com/logos-storage/logos-storage-go-bindings-example.
By default, Logos Storage builds a dynamic library (libstorage.so/libstorage.dylib/libstorage.dll), which you can load at runtime.
If you prefer a static library (libstorage.a), set the STATIC flag:
# Build dynamic (default)
make libstorage
# Build static
make STATIC=1 libstorageCallbacks must be fast and non-blocking; otherwise, the working thread will hang and prevent other requests from being processed.
# Run unit tests (tests/storage/)
make test
# Run integration tests (spawns real node processes)
make testIntegration
# Run one integration test file (path from tests/)
STORAGE_INTEGRATION_TEST_INCLUDES="integration/5_minutes/testrestapivalidation.nim" \
nim testIntegration build.nims
# Keep the node logs, in tests/integration/logs/
STORAGE_INTEGRATION_TEST_INCLUDES="integration/5_minutes/testrestapivalidation.nim" \
nim testIntegration -d:StorageLogToFile=true build.nims
# Run all tests
make testAll
# Run a single test file directly
nim c -r tests/storage/testblockexchange.nim
# Run C bindings test
make testLibstorage
# Coverage report (requires lcov)
make coverage && make show-coverageAdd Logos Storage to the .nimble file of your project:
requires "https://github.com/logos-storage/logos-storage-nim"Nimble resolves the version ranges of storage.nimble. It does not read nimble.lock.
Nim reads only the config.nims of the project it compiles, not the one of Logos Storage. Add these settings to your config.nims:
--threads:on
--mm:refc
switch("define", "libp2p_multicodec_exts:storage/multicodec_exts.nim")
switch("define", "libp2p_multihash_exts:storage/multihash_exts.nim")
switch("define", "libp2p_contentids_exts:storage/contentids_exts.nim")
switch("define", "libp2p_multiaddress_exts:storage/multiaddress_exts.nim")
switch("define", "libp2p_pki_schemes=secp256k1")
switch("define", "chronicles_sinks=textlines[dynamic],json[dynamic],textlines[dynamic]")
switch("define", "chronosHandleException")
switch("define", "nimOldCaseObjects")
switch("define", "withoutPCRE")
switch("define", "use_asm_syntax_intel=false")
switch("define", "ctt_asm=true")
switch("legacy", "procParamTypeBackendAliases")Then import the modules you need, for example import pkg/storage/storage.
Feel free to dive in, contributions are welcomed! Open an issue or submit PRs.
logos-storage-nim uses 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-hook, which will format modified files prior committing them.
If you are using VSCode and the NimLang extension you can enable "Format On Save" (eq. the nim.formatOnSave property) that will format the files using nph.