unc_primitives/
epoch_sync.rs

1use crate::block_header::BlockHeader;
2use crate::epoch_manager::block_info::BlockInfo;
3use crate::epoch_manager::epoch_info::EpochInfo;
4use crate::merkle::PartialMerkleTree;
5use crate::views::LightClientBlockView;
6use borsh::{BorshDeserialize, BorshSerialize};
7
8#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
9pub struct EpochSyncFinalizationResponse {
10    pub cur_epoch_header: BlockHeader,
11    pub prev_epoch_headers: Vec<BlockHeader>,
12    pub header_sync_init_header: BlockHeader,
13    pub header_sync_init_header_tree: PartialMerkleTree,
14    // This Block Info is required by Epoch Manager when it checks if it's a good time to start a new Epoch.
15    // Epoch Manager asks for height difference by obtaining first Block Info of the Epoch.
16    pub prev_epoch_first_block_info: BlockInfo,
17    // This Block Info is required in State Sync that is started right after Epoch Sync is finished.
18    // It is used by `verify_chunk_signature_with_header_parts` in `save_block` as it calls `get_epoch_id_from_prev_block`.
19    pub prev_epoch_prev_last_block_info: BlockInfo,
20    // This Block Info is connected with the first actual Block received in State Sync.
21    // It is also used in Epoch Manager.
22    pub prev_epoch_last_block_info: BlockInfo,
23    pub prev_epoch_info: EpochInfo,
24    pub cur_epoch_info: EpochInfo,
25    // Next Epoch Info is required by Block Sync when Blocks of current Epoch will come.
26    // It asks in `process_block_single`, returns `Epoch Out Of Bounds` error otherwise.
27    pub next_epoch_info: EpochInfo,
28}
29
30#[derive(BorshSerialize, BorshDeserialize, Eq, PartialEq, Debug, Clone)]
31pub enum EpochSyncResponse {
32    UpToDate,
33    Advance { light_client_block_view: Box<LightClientBlockView> },
34}