(state: &mut FvmExecState<SS>)
| 20 | |
| 21 | impl 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 |
nothing calls this directly
no test coverage detected