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
// Copyright 2019 Conflux Foundation. All rights reserved.
// Conflux is free software and distributed under GNU General Public License.
// See http://www.gnu.org/licenses/

/// Archive nodes and full nodes react differently for snapshot management.
pub trait SnapshotManagerTrait: GetSnapshotDbManager {
    // FIXME: add check_make_register_snapshot_background into trait

    fn get_snapshot_by_epoch_id(
        &self, epoch_id: &EpochId, try_open: bool, open_mpt_snapshot: bool,
    ) -> Result<Option<Self::SnapshotDb>> {
        self.get_snapshot_db_manager().get_snapshot_by_epoch_id(
            epoch_id,
            try_open,
            open_mpt_snapshot,
        )
    }

    fn remove_old_pivot_snapshot(
        &self, snapshot_epoch_id: &EpochId,
    ) -> Result<()>;

    fn remove_non_pivot_snapshot(
        &self, snapshot_epoch_id: &EpochId,
    ) -> Result<()>;
}

pub trait GetSnapshotDbManager {
    type SnapshotDb: SnapshotDbTrait<ValueType = Box<[u8]>>;
    type SnapshotDbManager: SnapshotDbManagerTrait<
        SnapshotDb = Self::SnapshotDb,
    >;

    fn get_snapshot_db_manager(&self) -> &Self::SnapshotDbManager;
}

use super::{
    impls::errors::*,
    storage_db::{snapshot_db::*, snapshot_db_manager::*},
};
use primitives::EpochId;