From 6f1d8d27d24653b0af1998d0f3e148e347db9ee0 Mon Sep 17 00:00:00 2001 From: Aleksandar Djuric Date: Thu, 21 Dec 2023 17:20:50 -0500 Subject: [PATCH 1/2] Added example using quill --- examples/quill/README.md | 13 +++++++++++++ examples/quill/daemon.toml | 27 +++++++++++++++++++++++++++ examples/quill/docker-compose.yaml | 13 +++++++++++++ examples/quill/reduce.js | 22 ++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 examples/quill/README.md create mode 100644 examples/quill/daemon.toml create mode 100644 examples/quill/docker-compose.yaml create mode 100644 examples/quill/reduce.js diff --git a/examples/quill/README.md b/examples/quill/README.md new file mode 100644 index 0000000..538e7f1 --- /dev/null +++ b/examples/quill/README.md @@ -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 +``` \ No newline at end of file diff --git a/examples/quill/daemon.toml b/examples/quill/daemon.toml new file mode 100644 index 0000000..7667562 --- /dev/null +++ b/examples/quill/daemon.toml @@ -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/deno/reduce.js" +use_async = true + +[storage] +type = "Redis" +url = "redis://127.0.0.1/1" + diff --git a/examples/quill/docker-compose.yaml b/examples/quill/docker-compose.yaml new file mode 100644 index 0000000..09b099e --- /dev/null +++ b/examples/quill/docker-compose.yaml @@ -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 diff --git a/examples/quill/reduce.js b/examples/quill/reduce.js new file mode 100644 index 0000000..af663cb --- /dev/null +++ b/examples/quill/reduce.js @@ -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) +} From c16217d0d49e08da71bab2674351ecff105b9141 Mon Sep 17 00:00:00 2001 From: Aleksandar Djuric Date: Sat, 23 Dec 2023 16:46:42 -0500 Subject: [PATCH 2/2] Fixed path error --- examples/quill/daemon.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/quill/daemon.toml b/examples/quill/daemon.toml index 7667562..d4be273 100644 --- a/examples/quill/daemon.toml +++ b/examples/quill/daemon.toml @@ -18,7 +18,7 @@ db_path = "./sled" [reducer] type = "Deno" -main_module = "./examples/deno/reduce.js" +main_module = "./examples/quill/reduce.js" use_async = true [storage]