Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added example using quill #159

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions examples/quill/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Quill

[Quill](https://github.com/alethea-io/quill) is a library of reducers written in Javascript that are compatible with Scrolls.

## Setup Redis DB
```bash
docker compose up -d
```

## Run scrolls
```bash
RUST_BACKTRACE=1 cargo run --features deno --bin scrolls -- daemon --config ./examples/quill/daemon.toml
```
27 changes: 27 additions & 0 deletions examples/quill/daemon.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[source]
type = "N2N"
peers = ["relays-new.cardano-mainnet.iohk.io:3001"]

[chain]
type = "mainnet"

[intersect]
type = "Point"
value = [
104699772,
"19525913a14c4540a782d188c333f2c54d1845620aef56e3166a2c1fffb800fc"
]

[enrich]
type = "Sled"
db_path = "./sled"

[reducer]
type = "Deno"
main_module = "./examples/quill/reduce.js"
use_async = true

[storage]
type = "Redis"
url = "redis://127.0.0.1/1"

13 changes: 13 additions & 0 deletions examples/quill/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "3"

services:
redis:
image: redis
container_name: redis
ports:
- 6379:6379
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 5
22 changes: 22 additions & 0 deletions examples/quill/reduce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as reducers from "https://raw.githubusercontent.com/alethea-io/quill/main/dist/mod.js"

const config = [
{
name: "BalanceByAddress",
config: {
addressType: "payment",
prefix: "balance_by_address",
}
},
{
name: "BalanceByAddress",
config: {
addressType: "stake",
prefix: "balance_by_stake_address",
}
},
]

export async function reduce(blockJson) {
return reducers.apply(blockJson, config)
}