MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / new_from_state

Method new_from_state

fendermint/app/src/validators.rs:22–41  ·  view source on GitHub ↗
(state: &mut FvmExecState<SS>)

Source from the content-addressed store, hash-verified

20
21impl ValidatorCache {
22 pub fn new_from_state<SS>(state: &mut FvmExecState<SS>) -> Result<Self>
23 where
24 SS: Blockstore + Clone + 'static,
25 {
26 let gateway = GatewayCaller::default();
27 let (_, validators) = gateway.current_power_table(state)?;
28
29 let map = validators
30 .iter()
31 .map(|v| {
32 let tendermint_pub_key: TendermintPubKey =
33 TendermintPubKey::try_from(v.public_key.clone())?;
34 let id = TendermintId::from(tendermint_pub_key);
35 let key = *v.public_key.public_key();
36 Ok((id, key))
37 })
38 .collect::<Result<HashMap<_, _>, _>>()?;
39
40 Ok(Self { map })
41 }
42
43 pub fn get_validator(&self, id: &tendermint::account::Id) -> Result<PublicKey> {
44 self.map

Callers

nothing calls this directly

Calls 3

current_power_tableMethod · 0.80
iterMethod · 0.45
public_keyMethod · 0.45

Tested by

no test coverage detected