From 7f509880641859138796ffeb228c7a32e782196b Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Sun, 7 Jul 2024 12:43:30 +0200 Subject: [PATCH] replace graph_out with map_clock --- Makefile | 4 ++-- src/index.rs | 4 ++-- src/lib.rs | 2 +- src/maps.rs | 7 +++++++ src/sinks.rs | 21 --------------------- substreams.yaml | 6 +++--- 6 files changed, 15 insertions(+), 29 deletions(-) create mode 100644 src/maps.rs delete mode 100644 src/sinks.rs diff --git a/Makefile b/Makefile index fe96de0..38a21a3 100644 --- a/Makefile +++ b/Makefile @@ -23,11 +23,11 @@ info: .PHONY: run run: - substreams run -e eth.substreams.pinax.network:443 graph_out -s -100 + substreams run -e eth.substreams.pinax.network:443 map_clock -s -100 --production-mode .PHONY: gui gui: - substreams gui -e eth.substreams.pinax.network:443 graph_out -s 1000 -t 1001 + substreams gui -e eth.substreams.pinax.network:443 map_clock -s 1 -t 100000 --production-mode .PHONY: deploy deploy: diff --git a/src/index.rs b/src/index.rs index e83352c..9241933 100644 --- a/src/index.rs +++ b/src/index.rs @@ -8,7 +8,7 @@ fn block_index(min_block: Deltas) -> Result { Ok(match min_block.deltas[0].operation != Operation::Create { true => Keys::default(), false => Keys { - keys: vec!["clock".to_string()], + keys: vec!["daily".to_string()], }, }) -} +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 6d65a94..ae14282 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,3 @@ -mod sinks; +mod maps; mod index; mod stores; \ No newline at end of file diff --git a/src/maps.rs b/src/maps.rs new file mode 100644 index 0000000..cb96260 --- /dev/null +++ b/src/maps.rs @@ -0,0 +1,7 @@ +use substreams::errors::Error; +use substreams::pb::substreams::Clock; + +#[substreams::handlers::map] +pub fn map_clock(clock: Clock) -> Result { + Ok(clock) +} \ No newline at end of file diff --git a/src/sinks.rs b/src/sinks.rs deleted file mode 100644 index 0fedcd4..0000000 --- a/src/sinks.rs +++ /dev/null @@ -1,21 +0,0 @@ -use substreams::errors::Error; -use substreams::pb::substreams::Clock; -use substreams_entity_change::pb::entity::EntityChanges; -use substreams_entity_change::tables::Tables; - -#[substreams::handlers::map] -pub fn graph_out(clock: Clock) -> Result { - let mut tables = Tables::new(); - let timestamp = clock.timestamp.unwrap(); - let day = timestamp.seconds / 86400; - - tables - .create_row("Clock", &clock.id) - .set_bigint("day", &day.to_string()) - .set_bigint("number", &clock.number.to_string()) - .set_bigint("seconds", ×tamp.seconds.to_string()) - .set_bigint("nanos", ×tamp.nanos.to_string()) - .set("timestamp", timestamp.to_string()); - - Ok(tables.to_entity_changes()) -} \ No newline at end of file diff --git a/substreams.yaml b/substreams.yaml index 11c669c..35d90c1 100644 --- a/substreams.yaml +++ b/substreams.yaml @@ -29,14 +29,14 @@ modules: output: type: proto:sf.substreams.index.v1.Keys - - name: graph_out + - name: map_clock kind: map inputs: - source: sf.substreams.v1.Clock blockFilter: module: block_index query: - string: clock + string: daily params: false output: - type: proto:sf.substreams.sink.entity.v1.EntityChanges \ No newline at end of file + type: proto:sf.substreams.v1.Clock