soil_network/common/sync.rs
1// This file is part of Soil.
2
3// Copyright (C) Soil contributors.
4// Copyright (C) Parity Technologies (UK) Ltd.
5// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
6
7//! Abstract interfaces and data structures related to network sync.
8
9pub mod message;
10
11/// Sync operation mode.
12#[derive(Copy, Clone, Debug, Eq, PartialEq)]
13pub enum SyncMode {
14 /// Full block download and verification.
15 Full,
16 /// Download blocks and the latest state.
17 LightState {
18 /// Skip state proof download and verification.
19 skip_proofs: bool,
20 /// Download indexed transactions for recent blocks.
21 storage_chain_mode: bool,
22 },
23 /// Warp sync - verify authority set transitions and the latest state.
24 Warp,
25}
26
27impl SyncMode {
28 /// Returns `true` if `self` is [`Self::Warp`].
29 pub fn is_warp(&self) -> bool {
30 matches!(self, Self::Warp)
31 }
32
33 /// Returns `true` if `self` is [`Self::LightState`].
34 pub fn light_state(&self) -> bool {
35 matches!(self, Self::LightState { .. })
36 }
37}
38
39impl Default for SyncMode {
40 fn default() -> Self {
41 Self::Full
42 }
43}