use std::sync::Arc;
use cid::Cid;
use fvm_ipld_blockstore::Blockstore;
use super::{ActorMigration, ActorMigrationInput, ActorMigrationOutput};
pub(in crate::state_migration) struct NilMigrator(Cid);
impl<BS: Blockstore> ActorMigration<BS> for NilMigrator {
fn migrate_state(
&self,
_store: &BS,
input: ActorMigrationInput,
) -> anyhow::Result<Option<ActorMigrationOutput>> {
Ok(Some(ActorMigrationOutput {
new_code_cid: self.0,
new_head: input.head,
}))
}
}
pub(in crate::state_migration) fn nil_migrator<BS: Blockstore>(
cid: Cid,
) -> Arc<dyn ActorMigration<BS> + Send + Sync> {
Arc::new(NilMigrator(cid))
}
pub(in crate::state_migration) struct DeferredMigrator;
impl<BS: Blockstore> ActorMigration<BS> for DeferredMigrator {
fn migrate_state(
&self,
_store: &BS,
_input: ActorMigrationInput,
) -> anyhow::Result<Option<ActorMigrationOutput>> {
Ok(None)
}
}