ex3_deposit_detector_client/
lib.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
use async_trait::async_trait;
use ex3_canister_client::{ActorResult, CanisterResult};
use ex3_canister_types::pager::{GetPageInput, GetPageOutput};
#[cfg(feature = "canister")]
use ex3_core_registry_public_types::{
    NodeProviderFullSyncRequest, NodeProviderIncrementalSyncRequest,
};
use ex3_deposit_detector_public_types::{ShardingReportProgressInfo, ShardingSubReport};
use ex3_node_types::{transaction::CandidVerifiedDeposit, CandidBlockHeight};

#[cfg(feature = "canister")]
pub mod canister_impl;
#[cfg(feature = "agent")]
pub mod client_impl;
#[cfg(feature = "mock")]
pub mod mock;

#[async_trait]
pub trait DepositDetector: Send + Sync {
    async fn get_current_block_height(&self) -> CanisterResult<CandidBlockHeight>;

    async fn get_current_snapshot_height(&self) -> CanisterResult<Option<CandidBlockHeight>>;

    async fn apply_to_be_a_submitter(
        &self,
        height: CandidBlockHeight,
    ) -> CanisterResult<ActorResult<()>>;

    async fn submit_sharding_sub_report(
        &self,
        block_height: CandidBlockHeight,
        sub_report: ShardingSubReport,
    ) -> CanisterResult<ActorResult<()>>;

    async fn validate_or_drop_sharding_report(
        &self,
        block_height: CandidBlockHeight,
    ) -> CanisterResult<ActorResult<()>>;

    async fn commit_sharding_report(
        &self,
        block_height: CandidBlockHeight,
    ) -> CanisterResult<ActorResult<bool>>;

    async fn get_verified_deposits_by_page(
        &self,
        pager: GetPageInput,
    ) -> CanisterResult<ActorResult<GetPageOutput<CandidVerifiedDeposit>>>;

    async fn get_verified_deposits_by_page_with_verified_at_limitation(
        &self,
        pager: GetPageInput,
        verified_at_start: Option<CandidBlockHeight>,
    ) -> CanisterResult<ActorResult<GetPageOutput<CandidVerifiedDeposit>>>;

    async fn get_consumed_deposits_by_page(
        &self,
        pager: GetPageInput,
        limit_height: Option<CandidBlockHeight>,
    ) -> CanisterResult<ActorResult<GetPageOutput<CandidVerifiedDeposit>>>;

    async fn get_consumed_deposits_by_page_with_verified_at_limitation(
        &self,
        pager: GetPageInput,
        verified_at_start: Option<CandidBlockHeight>,
        limit_height: Option<CandidBlockHeight>,
    ) -> CanisterResult<ActorResult<GetPageOutput<CandidVerifiedDeposit>>>;

    async fn get_sharding_report_progress_info(&self)
        -> CanisterResult<ShardingReportProgressInfo>;

    #[cfg(feature = "canister")]
    async fn sync_node_provider(
        &self,
        full_sync_request: NodeProviderFullSyncRequest,
    ) -> CanisterResult<ActorResult<()>>;

    #[cfg(feature = "canister")]
    async fn accept_node_provider_update(
        &self,
        incremental_sync_request: NodeProviderIncrementalSyncRequest,
    ) -> CanisterResult<ActorResult<()>>;

    #[cfg(feature = "canister")]
    async fn sync_chain_nodes(
        &self,
        chain: ex3_node_types::chain::CandidChain,
        chain_nodes: Vec<String>,
        version: u64,
    ) -> CanisterResult<ActorResult<()>>;
}