forked from gcarq/rusty-blockparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.rs
41 lines (33 loc) · 1.26 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use clap::{ArgMatches, Command};
use crate::blockchain::proto::block::Block;
use crate::errors::OpResult;
pub mod balances;
mod common;
pub mod csvdump;
pub mod opreturn;
pub mod simplestats;
pub mod unspentcsvdump;
/// Implement this trait for a custom Callback.
/// The parser ensures that the blocks arrive in the correct order.
/// At this stage the main chain is already determined and orphans/stales are removed.
pub trait Callback {
/// Builds Command to specify callback name and required args,
/// exits if some required args are missing.
fn build_subcommand() -> Command
where
Self: Sized;
/// Instantiates callback
fn new(matches: &ArgMatches) -> OpResult<Self>
where
Self: Sized;
/// Gets called shortly before the blocks are parsed.
fn on_start(&mut self, block_height: u64) -> OpResult<()>;
/// Gets called if a new block is available.
fn on_block(&mut self, block: &Block, block_height: u64) -> OpResult<()>;
/// Gets called if the parser has finished and all blocks are handled
fn on_complete(&mut self, block_height: u64) -> OpResult<()>;
/// Can be used to toggle whether the progress should be shown for specific callbacks or not
fn show_progress(&self) -> bool {
true
}
}