Last active
April 27, 2023 14:22
-
-
Save ra0x3/dd3508c4e3dc982d940f3aa23f8ac468 to your computer and use it in GitHub Desktop.
Example indexer lib
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
extern crate alloc; | |
use fuel_indexer_macros::indexer; | |
use fuel_indexer_plugin::prelude::*; | |
#[indexer(manifest = "tech_talk.manifest.yaml")] | |
pub mod tech_talk_index_mod { | |
fn tech_talk_handler(block_data: BlockData) { | |
Logger::info("Processing a block. (>'.')>"); | |
let block_id = first8_bytes_to_u64(block_data.id); | |
let block = Block{ id: block_id, height: block_data.height, hash: block_data.id }; | |
block.save(); | |
for transaction in block_data.transactions.iter() { | |
Logger::info("Handling a transaction (>'.')>"); | |
let tx = Tx{ id: first8_bytes_to_u64(transaction.id), block: block_id, hash: transaction.id }; | |
tx.save(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment