docs: add functionality, and usage

others:

* remove drop command from sql migration
This commit is contained in:
2023-01-11 09:29:16 +00:00
parent f1e74961b0
commit 42bc68024f
8 changed files with 92 additions and 9 deletions

11
docs/filters.md Normal file
View File

@@ -0,0 +1,11 @@
## Writing filters
Filters must conform to the interface:
```go
type Filter interface {
Execute(ctx context.Context, inputTransaction fetch.Transaction) (next bool, err error)
}
```
See examples in the `internal/filter` folder.

30
docs/functionality.md Normal file
View File

@@ -0,0 +1,30 @@
## Functionality
### Head syncer
Opens a websocket connection and processes live transactions.
### Janitor
Periodically checks for missed (and historical) blocks missed by the head syncer and queues them for processing. A gap range is processed twice to guarantee there is no missing block.
### Pipeline
Fetches a block and executes the filters in serial order for every transaction in the block before finally committing the block to the store.
### Filter
Processes a transaction and passes it on to the next filter or terminates the pipeline for that transaction if it is irrelevant.
### Store schema
- The `blocks` table keeps track of processed blocks.
- The `syncer_meta` table keeps track of the lower_bound cursor. Below the lower_bound cursor, all blocks are guarnteed to have been processsed hence it is safe to trim the `blocks` table below that pointer.
### GraphQL
- Fetches a block (and some of its header details), transactions and transaction receipts embedded within the transaction object in a single call.
## Caveats
- Blocks are not guaranteed to be processed in order, however a low concurrency setting would somewhat give an "in-order" behaviour (not to be relied upon in any case).

36
docs/usage.md Normal file
View File

@@ -0,0 +1,36 @@
## Requirements
- Celo (geth) node with GraphQL enabled
- Postgres 14+
## Running
### 1. Run migrations
Run the migrations inside the `migrations` folder.
### 2. Update the config
The base config is described in `config.toml`. Values can be overriden with env variables e.g. to disable metrics, set `METRICS_GO_PROCESS=false`.
### 3. Start the service:
**Compiling**:
- Requires CGO_ENABLED=1
- Prebuilt binaries (for amd64 only) available on the releases page
**Docker**:
- `docker pull ghcr.io/grassrootseconomics/cic-chain-events/cic-chain-events:latest`
After compiling or within a Docker container:
`$ ./cic-chain-events`
Optional flags:
- `-config` - `config.toml` file path
- `-debug` - Enable/disable debug level logs
- `-queries` - `queries.sql` file path