-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(rpc): new state manager api to simplify actor state loading log…
…ic (#4560)
- Loading branch information
1 parent
776b99f
commit 9d9b0af
Showing
4 changed files
with
72 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2019-2024 ChainSafe Systems | ||
// SPDX-License-Identifier: Apache-2.0, MIT | ||
|
||
use crate::shim::{address::Address, state_tree::ActorState}; | ||
use fvm_ipld_blockstore::Blockstore; | ||
|
||
pub trait LoadActorStateFromBlockstore: Sized { | ||
const ACTOR: Option<Address> = None; | ||
|
||
fn load(store: &impl Blockstore, actor: &ActorState) -> anyhow::Result<Self>; | ||
} | ||
|
||
mod load_actor_state_trait_impl { | ||
use super::*; | ||
|
||
macro_rules! impl_for { | ||
($actor:ident $(, $addr:expr)?) => { | ||
impl LoadActorStateFromBlockstore for fil_actor_interface::$actor::State { | ||
$(const ACTOR: Option<Address> = Some($addr);)? | ||
fn load(store: &impl Blockstore, actor: &ActorState) -> anyhow::Result<Self> { | ||
Self::load(store, actor.code, actor.state) | ||
} | ||
} | ||
}; | ||
} | ||
|
||
impl_for!(account); | ||
impl_for!(cron, Address::CRON_ACTOR); | ||
impl_for!(datacap, Address::DATACAP_TOKEN_ACTOR); | ||
impl_for!(evm); | ||
impl_for!(init, Address::INIT_ACTOR); | ||
impl_for!(market, Address::MARKET_ACTOR); | ||
impl_for!(miner); | ||
impl_for!(multisig); | ||
impl_for!(power, Address::POWER_ACTOR); | ||
impl_for!(reward, Address::REWARD_ACTOR); | ||
impl_for!(system, Address::SYSTEM_ACTOR); | ||
impl_for!(verifreg, Address::VERIFIED_REGISTRY_ACTOR); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
// Copyright 2019-2024 ChainSafe Systems | ||
// SPDX-License-Identifier: Apache-2.0, MIT | ||
|
||
pub mod common; | ||
pub mod market; | ||
pub mod miner; | ||
pub mod multisig; | ||
pub mod verifreg; | ||
|
||
pub use common::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters