-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Code refactoring and comments (#16) * Fix typo and console highlights in README * Fix wrong environment variables names
- Loading branch information
Showing
11 changed files
with
196 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,93 @@ | ||
# substreams-clock-api | ||
# [`Substreams`](https://substreams.streamingfast.io/) Clock API | ||
|
||
[![.github/workflows/bun-test.yml](https://github.com/pinax-network/substreams-clock-api/actions/workflows/bun-test.yml/badge.svg)](https://github.com/pinax-network/substreams-clock-api/actions/workflows/bun-test.yml) | ||
|
||
> Timestamps <> Block numbers conversion for your favorite chains | ||
> Convert Timestamps <> Block numbers and query latest blocks height for your favorite chains ! | ||
## REST API | ||
|
||
| Pathname | Description | | ||
|-------------------------------------------|-----------------------| | ||
| GET `/` | Banner | ||
| GET `/chains` | Returns all available `chains` | ||
| GET `/health` | Health check | ||
| ~~GET `/metrics`~~ (SOON) | ~~Prometheus metrics~~ | ||
| GET `/openapi` | [OpenAPI v3 JSON](https://spec.openapis.org/oas/v3.0.0) | ||
| GET `/swagger` | [Swagger UI](https://swagger.io/resources/open-api/) | ||
| GET `/{chain}/current` | Latest block number on the chain | ||
| GET `/{chain}/final` | Latest finalized block number on the chain | ||
| GET `/{chain}/timestamp?block_number=` | Timestamp query from a block number or array (comma-separated) | ||
| GET `/{chain}/blocknum?timestamp=` | Block number query from a timestamp or array (comma-separated) | ||
|
||
## Requirements | ||
|
||
- [Clickhouse](clickhouse.com/) | ||
|
||
Additionnaly to pull data directly from a substream: | ||
- [Substreams Sink Clickhouse](https://github.com/pinax-network/substreams-sink-clickhouse/) | ||
|
||
## Quickstart | ||
|
||
```console | ||
$ bun install | ||
$ bun dev | ||
``` | ||
|
||
## [`Bun` Binary Releases](https://github.com/pinax-network/substreams-sink-websockets/releases) | ||
|
||
> Linux Only | ||
```console | ||
$ wget https://github.com/pinax-network/substreams-clock-api/releases/download/v0.2.0/substreams-clock-api | ||
$ chmod +x ./substreams-clock-api | ||
``` | ||
|
||
## `.env` Environment variables | ||
|
||
```env | ||
# Optional | ||
PORT=8080 | ||
HOSTNAME=localhost | ||
DB_HOST=http://localhost:8123 | ||
DB_NAME=demo | ||
DB_USERNAME=default | ||
DB_PASSWORD= | ||
``` | ||
|
||
## Help | ||
|
||
```console | ||
$ ./substreams-clock-api --help | ||
Usage: substreams-clock-api [options] | ||
|
||
Timestamps <> Block numbers conversion for your favorite chains | ||
|
||
Options: | ||
--port <int> Server listen on HTTP port (default: "8080", env: PORT) | ||
--hostname <string> Server listen on HTTP hostname (default: "localhost", env: HOST) | ||
--db-host <string> Clickhouse DB HTTP hostname (default: "http://localhost:8123", env: dbHost) | ||
--name <string> Clickhouse DB table name (default: "demo", env: DB_NAME) | ||
--username <string> Clickhouse DB username (default: "default", env: DB_USERNAME) | ||
--password <string> Clickhouse DB password (default: "", env: DB_PASSWORD) | ||
--max-elements-queried <string> Maximum number of query elements when using arrays as parameters (default: 10, env: MAX_ELEMENTS_QUERIED) | ||
--verbose <boolean> Enable verbose logging (default: false, env: VERBOSE) | ||
-V, --version output the version number | ||
-h, --help display help for command | ||
``` | ||
|
||
## Docker environment (SOON) | ||
|
||
<!-- Pull from GitHub Container registry | ||
```bash | ||
docker pull ghcr.io/pinax-network/substreams-sink-websockets:latest | ||
``` | ||
Build from source | ||
```bash | ||
docker build -t substreams-sink-websockets . | ||
``` | ||
Run with `.env` file | ||
```bash | ||
docker run -it --rm --env-file .env ghcr.io/pinax-network/substreams-sink-websockets | ||
``` --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.