forked from gcarq/rusty-blockparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.rs
33 lines (25 loc) · 1.2 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
pub mod stats;
pub mod csvdump;
pub mod unspentcsvdump;
use clap::{ArgMatches, App};
use errors::OpResult;
use blockchain::proto::block::Block;
use blockchain::parser::types::CoinType;
/// 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.
/// Note: These callbacks are only triggered with ParseMode::FullData.
/// (The first run to determine longest chain is running in ParseMode::Indexing)
pub trait Callback {
/// Builds SubCommand to specify callback name and required args,
/// exits if some required args are missing.
fn build_subcommand<'a, 'b>() -> App<'a, 'b> where Self: Sized;
/// Instantiates callback
fn new(matches: &ArgMatches) -> OpResult<Self> where Self: Sized;
/// Gets called shortly before the threads are invoked.
fn on_start(&mut self, coin_type: CoinType, block_height: usize);
/// Gets called if a new block is available.
fn on_block(&mut self, block: Block, block_height: usize);
/// Gets called if the dispatcher has finished and all blocks are handled
fn on_complete(&mut self, block_height: usize);
}