1use anyhow::Result;
6use async_trait::async_trait;
7use cfx_types::H256;
8use serde::{Deserialize, Serialize};
9
10#[async_trait]
11pub trait PowInterface: Send + Sync {
12 async fn next_pivot_decision(
14 &self, parent_decision: H256,
15 ) -> Option<(u64, H256)>;
16
17 fn validate_proposal_pivot_decision(
18 &self, parent_decision: H256, me_decision: H256,
19 ) -> bool;
20
21 fn get_staking_events(
22 &self, parent_height: u64, me_height: u64, parent_decision: H256,
23 me_decision: H256,
24 ) -> Result<Vec<StakingEvent>>;
25
26 async fn wait_for_initialization(&self, last_decision: H256);
27
28 fn is_normal_phase(&self) -> bool;
29}
30
31#[derive(Debug, Eq, PartialEq, Serialize, Deserialize)]
32pub enum StakingEvent {
33 Register(H256, Vec<u8>, Vec<u8>),
35 IncreaseStake(H256, u64),
37 Retire(H256, u64),
39}
40
41pub struct FakePowHandler {}
44
45#[async_trait]
46impl PowInterface for FakePowHandler {
47 async fn next_pivot_decision(
48 &self, _parent_decision: H256,
49 ) -> Option<(u64, H256)> {
50 todo!()
51 }
52
53 fn validate_proposal_pivot_decision(
54 &self, _parent_decision: H256, _me_decision: H256,
55 ) -> bool {
56 todo!()
57 }
58
59 fn get_staking_events(
60 &self, _parent_height: u64, _me_height: u64, _parent_decision: H256,
61 _me_decision: H256,
62 ) -> Result<Vec<StakingEvent>> {
63 todo!()
64 }
65
66 async fn wait_for_initialization(&self, _last_decision: H256) { todo!() }
67
68 fn is_normal_phase(&self) -> bool { todo!() }
69}