1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2019-2024 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use std::sync::Arc;

use crate::cid_collections::CidHashMap;
use crate::shim::state_tree::StateTree;

use super::Migrator;

/// The implementation should verify that the migration specification is
/// correct. This is to prevent accidental migration errors.
pub(in crate::state_migration) trait ActorMigrationVerifier<BS> {
    fn verify_migration(
        &self,
        store: &BS,
        migrations: &CidHashMap<Migrator<BS>>,
        actors_in: &StateTree<BS>,
    ) -> anyhow::Result<()>;
}

/// Type implementing the `ActorMigrationVerifier` trait.
pub(in crate::state_migration) type MigrationVerifier<BS> =
    Arc<dyn ActorMigrationVerifier<BS> + Send + Sync>;