mirror of
https://github.com/oxen-io/oxen-storage-server.git
synced 2023-12-13 21:00:26 +01:00
69d3e8c380
Refactors how stats are collected: - Keeping a rolling window of recent stats for every 10 minutes over the past hour so that when we rotate stats, we only chop off the 1h10min-1h counts, but always have a recent stats counter that reflects the last ~1h of requests. - Move the stats cleanup timer into the stats class itself - Make the all_stats class properly thread safe. Previously *parts* of it were thread safe but much of it wasn't, so really wasn't safe to be used without holding the owning service_node's global lock. - Fix various bugs in the stats values: - "reset_time" was never updated, but even if it had been, it was a steady_clock and being returned as time_since_epoch() which is a useless value. - recent_retrieve_requests wasn't being set at all in the returned json (instead recent_store_requests was set twice). - onion requests weren't being counted at all; instead every onion request bumped the proxy request counter - Got rid of exposing "current period" stats: instead we now just expose the recent request counters, which are calculated from current period + stored historic period values, thus giving you a count for requests over the last 1h5m (±5 minutes). - Replace time_t with modern time types - Don't indent/prettify json; in any case where you'd actually want it this is much better done via tools like `jq`. |
||
---|---|---|
.github/ISSUE_TEMPLATE | ||
.vscode | ||
cmake | ||
common | ||
contrib | ||
crypto | ||
httpserver | ||
storage | ||
unit_test | ||
utils | ||
vendors | ||
.clang-format | ||
.dockerignore | ||
.drone.jsonnet | ||
.gitignore | ||
.gitmodules | ||
CMakeLists.txt | ||
Dockerfile | ||
LICENSE | ||
Makefile | ||
mock_lokid.py | ||
README.md |
loki-storage-server
Storage server for Loki Service Nodes
Requirements:
- Boost >= 1.66 (for boost.beast)
- OpenSSL >= 1.1.1a (for X25519 curves)
- sodium >= 1.0.17 (for ed25119 to curve25519 conversion)
You can, however, download and build static versions these dependencies
as part of the build by adding the -DBUILD_STATIC_DEPS=ON
option to cmake.
Can use RelWithDebInfo
instead of Release
if you want to include debug symbols to provide developers with valueable core dumps from crashes.
Also make sure you don't have an older (than 4.3.0) libzmq header in /usr/local/include, if so please install a new version.
git submodule update --init --recursive
mkdir build && cd build
cmake -DDISABLE_SNODE_SIGNATURE=OFF -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
./loki-storage 0.0.0.0 8080
The paths for Boost and OpenSSL can be specified by exporting the variables in the terminal before running make
:
export OPENSSL_ROOT_DIR = ...
export BOOST_ROOT= ...
Then using something like Postman (https://www.getpostman.com/) you can hit the API:
post data
HTTP POST http://127.0.0.1/store
body: "hello world"
headers:
- X-Loki-recipient: "mypubkey"
- X-Loki-ttl: "86400"
- X-Loki-timestamp: "1540860811000"
- X-Loki-pow-nonce: "xxxx..."
get data
HTTP GET http://127.0.0.1/retrieve
headers:
- X-Loki-recipient: "mypubkey"
- X-Loki-last-hash: "" (optional)
unit tests
mkdir build_test
cd build_test
cmake ../unit_test -DBOOST_ROOT="path to boost" -DOPENSSL_ROOT_DIR="path to openssl"
cmake --build .
./Test --log_level=all