use crate::rpc::{ApiPaths, Ctx, Permission, RpcMethod, ServerError};
use crate::{beacon::BeaconEntry, shim::clock::ChainEpoch};
use anyhow::Result;
use fvm_ipld_blockstore::Blockstore;
pub enum BeaconGetEntry {}
impl RpcMethod<1> for BeaconGetEntry {
const NAME: &'static str = "Filecoin.BeaconGetEntry";
const PARAM_NAMES: [&'static str; 1] = ["first"];
const API_PATHS: ApiPaths = ApiPaths::V0; const PERMISSION: Permission = Permission::Read;
type Params = (ChainEpoch,);
type Ok = BeaconEntry;
async fn handle(
ctx: Ctx<impl Blockstore>,
(first,): Self::Params,
) -> Result<Self::Ok, ServerError> {
let (_, beacon) = ctx.beacon().beacon_for_epoch(first)?;
let rr =
beacon.max_beacon_round_for_epoch(ctx.state_manager.get_network_version(first), first);
let e = beacon.entry(rr).await?;
Ok(e)
}
}