forest/state_migration/common/
migrators.rs1use std::sync::Arc;
5
6use cid::Cid;
7use fvm_ipld_blockstore::Blockstore;
8
9use super::{ActorMigration, ActorMigrationInput, ActorMigrationOutput};
10
11pub(in crate::state_migration) struct NilMigrator(Cid);
14
15impl<BS: Blockstore> ActorMigration<BS> for NilMigrator {
16 fn migrate_state(
17 &self,
18 _store: &BS,
19 input: ActorMigrationInput,
20 ) -> anyhow::Result<Option<ActorMigrationOutput>> {
21 Ok(Some(ActorMigrationOutput {
22 new_code_cid: self.0,
23 new_head: input.head,
24 }))
25 }
26}
27
28pub(in crate::state_migration) fn nil_migrator<BS: Blockstore>(
31 cid: Cid,
32) -> Arc<dyn ActorMigration<BS> + Send + Sync> {
33 Arc::new(NilMigrator(cid))
34}
35
36pub(in crate::state_migration) struct DeferredMigrator;
38
39impl<BS: Blockstore> ActorMigration<BS> for DeferredMigrator {
40 fn migrate_state(
41 &self,
42 _store: &BS,
43 _input: ActorMigrationInput,
44 ) -> anyhow::Result<Option<ActorMigrationOutput>> {
45 Ok(None)
46 }
47}