1use cfx_rpc_cfx_types::{
6 pos::{
7 Account, Block, BlockNumber, CommitteeState, EpochState,
8 LedgerInfoWithSignatures, PoSEpochReward, Status, Transaction,
9 },
10 RpcAddress,
11};
12use cfx_types::{H256, U64};
13use jsonrpsee::{core::RpcResult, proc_macros::rpc};
14
15#[rpc(server, namespace = "pos")]
17pub trait PosRpc {
18 #[method(name = "getStatus")]
19 fn pos_status(&self) -> RpcResult<Status>;
20
21 #[method(name = "getAccount")]
22 fn pos_account(
23 &self, address: H256, view: Option<U64>,
24 ) -> RpcResult<Account>;
25
26 #[method(name = "getAccountByPowAddress")]
27 fn pos_account_by_pow_address(
28 &self, address: RpcAddress, view: Option<U64>,
29 ) -> RpcResult<Account>;
30
31 #[method(name = "getCommittee")]
32 fn pos_committee(&self, view: Option<U64>) -> RpcResult<CommitteeState>;
33
34 #[method(name = "getBlockByHash")]
35 fn pos_block_by_hash(&self, hash: H256) -> RpcResult<Option<Block>>;
36
37 #[method(name = "getBlockByNumber")]
38 fn pos_block_by_number(
39 &self, number: BlockNumber,
40 ) -> RpcResult<Option<Block>>;
41
42 #[method(name = "getTransactionByNumber")]
43 fn pos_transaction_by_number(
44 &self, number: U64,
45 ) -> RpcResult<Option<Transaction>>;
46
47 #[method(name = "getConsensusBlocks")]
49 fn pos_consensus_blocks(&self) -> RpcResult<Vec<Block>>;
50
51 #[method(name = "getEpochState")]
53 fn pos_get_epoch_state(&self, epoch: U64) -> RpcResult<Option<EpochState>>;
54
55 #[method(name = "getLedgerInfoByEpoch")]
57 fn pos_get_ledger_info_by_epoch(
58 &self, epoch: U64,
59 ) -> RpcResult<Option<LedgerInfoWithSignatures>>;
60
61 #[method(name = "getLedgerInfoByBlockNumber")]
62 fn pos_get_ledger_info_by_block_number(
63 &self, number: BlockNumber,
64 ) -> RpcResult<Option<LedgerInfoWithSignatures>>;
65
66 #[method(name = "getLedgerInfoByEpochAndRound")]
67 fn pos_get_ledger_info_by_epoch_and_round(
68 &self, epoch: U64, round: U64,
69 ) -> RpcResult<Option<LedgerInfoWithSignatures>>;
70
71 #[method(name = "getLedgerInfosByEpoch")]
73 fn pos_get_ledger_infos_by_epoch(
74 &self, start_epoch: U64, end_epoch: U64,
75 ) -> RpcResult<Vec<LedgerInfoWithSignatures>>;
76
77 #[method(name = "getRewardsByEpoch")]
78 fn pos_get_rewards_by_epoch(
79 &self, epoch: U64,
80 ) -> RpcResult<Option<PoSEpochReward>>;
81}