Skip to content

Commit

Permalink
add blocks substream
Browse files Browse the repository at this point in the history
  • Loading branch information
YaroShkvorets committed Jan 9, 2024
1 parent 494ced1 commit f4efbe7
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ members = [
"antelope.trxstats",
"bitcoin.ordinals",
"sx.stats",
"blocks",
]

[workspace.dependencies]
Expand Down
19 changes: 19 additions & 0 deletions blocks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "blocks"
version = "0.1.0"
authors = ["Yaro <[email protected]>"]
description = "Blocks Substream"
license = "MIT OR Apache-2.0"
edition = "2021"
publish = false

[badges]
maintenance = { status = "actively-developed" }

[lib]
crate-type = ["cdylib"]

[dependencies]
prost = { workspace = true }
prost-types = { workspace = true }
substreams = { workspace = true }
24 changes: 24 additions & 0 deletions blocks/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.PHONY: all
all:
make build
make pack
make graph
make info

.PHONY: build
build:
cargo build --target wasm32-unknown-unknown --release

.PHONY: pack
pack:
substreams pack

.PHONY: graph
graph:
substreams graph

.PHONY: info
info:
substreams info

%: ; @substreams gui -e $@.substreams.pinax.network:443 map_blocks -s -5
36 changes: 36 additions & 0 deletions blocks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Clock Substream

> Common "clock" substream that works for any substreams-instrumented firehose endpoint
## Usage
```bash
$ make build

$ make eth
$ make bitcoin
$ make bsc
$ make eos
```

## Graph
```mermaid
graph TD;
map_blocks[map: map_blocks];
sf.substreams.v1.Clock[source: sf.substreams.v1.Clock] --> map_blocks;
```

## Info
```yaml
Package name: blocks
Version: v0.1.0
Doc: Blocks
Modules:
----
Name: map_blocks
Initial block: 2
Kind: map
Input: source: sf.substreams.v1.Clock
Output Type: proto:sf.substreams.v1.Clock
Hash: 44c506941d5f30db6cca01692624395d1ac40cd1
```
6 changes: 6 additions & 0 deletions blocks/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use substreams::pb::substreams::Clock;

#[substreams::handlers::map]
pub fn map_blocks(clock: Clock) -> Result<Clock, substreams::errors::Error> {
Ok(clock)
}
20 changes: 20 additions & 0 deletions blocks/substreams.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
specVersion: v0.1.0
package:
name: blocks
version: v0.1.0
url: https://github.com/pinax-network/substreams
doc: Blocks

binaries:
default:
type: wasm/rust-v1
file: ../target/wasm32-unknown-unknown/release/blocks.wasm

modules:
- name: map_blocks
kind: map
initialBlock: 2
inputs:
- source: sf.substreams.v1.Clock
output:
type: proto:sf.substreams.v1.Clock

0 comments on commit f4efbe7

Please sign in to comment.