-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f2ae7f
commit 97f2f3b
Showing
11 changed files
with
265 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,15 @@ | ||
use substreams::errors::Error; | ||
use substreams::pb::substreams::Clock; | ||
use substreams_entity_change::pb::entity::EntityChanges; | ||
use substreams_entity_change::tables::Tables; | ||
use substreams_database_change::pb::database::DatabaseChanges; | ||
use substreams_ethereum::pb::eth::v2::Block; | ||
|
||
use crate::blocks::insert_blocks; | ||
// use crate::blocks::insert_blocks; | ||
use crate::logs::insert_logs; | ||
|
||
#[substreams::handlers::map] | ||
pub fn graph_out(clock: Clock, block: Block) -> Result<EntityChanges, Error> { | ||
let mut tables = Tables::new(); | ||
insert_blocks(&mut tables, &clock, &block); | ||
insert_logs(&mut tables, &clock, &block); | ||
Ok(tables.to_entity_changes()) | ||
} | ||
|
||
#[substreams::handlers::map] | ||
pub fn map_blocks(clock: Clock, block: Block) -> Result<EntityChanges, Error> { | ||
let mut tables = Tables::new(); | ||
insert_blocks(&mut tables, &clock, &block); | ||
Ok(tables.to_entity_changes()) | ||
} | ||
|
||
#[substreams::handlers::map] | ||
pub fn map_logs(clock: Clock, block: Block) -> Result<EntityChanges, Error> { | ||
let mut tables = Tables::new(); | ||
insert_logs(&mut tables, &clock, &block); | ||
Ok(tables.to_entity_changes()) | ||
pub fn ch_out(clock: Clock, block: Block) -> Result<DatabaseChanges, Error> { | ||
let mut tables: DatabaseChanges = DatabaseChanges::default(); | ||
// insert_blocks(&mut tables, &clock, &block); | ||
// insert_logs(&mut tables, &clock, &block); | ||
Ok(tables) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ version.workspace = true | |
|
||
[dependencies] | ||
substreams.workspace = true | ||
substreams-database-change.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use std::collections::HashMap; | ||
|
||
use substreams::pb::substreams::Clock; | ||
|
||
use crate::utils::block_time_to_date; | ||
|
||
pub fn block_keys(clock: &Clock) -> HashMap<String, String> { | ||
let timestamp = clock.clone().timestamp.unwrap(); | ||
let block_time = timestamp.to_string(); | ||
let block_number = clock.number.to_string(); | ||
let block_hash = format!("0x{}", clock.id); | ||
let block_date = block_time_to_date(block_time.as_str()).to_string(); | ||
|
||
HashMap::from([ | ||
("block_time".to_string(), block_time), | ||
("block_number".to_string(), block_number), | ||
("block_hash".to_string(), block_hash), | ||
("block_date".to_string(), block_date) | ||
]) | ||
} |
Oops, something went wrong.