From 0c0742e7544f789f286992e16106f51a95acf1c0 Mon Sep 17 00:00:00 2001 From: tom <69969590+simlecode@users.noreply.github.com> Date: Mon, 27 Jun 2022 18:15:20 +0800 Subject: [PATCH] fix: impl api BeaconGetEntry (#4989) --- app/submodule/chain/beacon.go | 27 ++++++++++++++++++++++++++ app/submodule/chain/chain_submodule.go | 1 + 2 files changed, 28 insertions(+) create mode 100644 app/submodule/chain/beacon.go diff --git a/app/submodule/chain/beacon.go b/app/submodule/chain/beacon.go new file mode 100644 index 0000000000..36883c3fb2 --- /dev/null +++ b/app/submodule/chain/beacon.go @@ -0,0 +1,27 @@ +package chain + +import ( + "context" + + "github.com/filecoin-project/go-state-types/abi" + v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" + "github.com/filecoin-project/venus/venus-shared/types" +) + +var _ v1api.IBeacon = &beaconAPI{} + +type beaconAPI struct { + chain *ChainSubmodule +} + +//NewBeaconAPI create a new beacon api +func NewBeaconAPI(chain *ChainSubmodule) v1api.IBeacon { + return &beaconAPI{chain: chain} +} + +// BeaconGetEntry returns the beacon entry for the given filecoin epoch. If +// the entry has not yet been produced, the call will block until the entry +// becomes available +func (beaconAPI *beaconAPI) BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) { + return beaconAPI.chain.API().StateGetBeaconEntry(ctx, epoch) +} diff --git a/app/submodule/chain/chain_submodule.go b/app/submodule/chain/chain_submodule.go index 7c39ceded5..56ac43287d 100644 --- a/app/submodule/chain/chain_submodule.go +++ b/app/submodule/chain/chain_submodule.go @@ -113,6 +113,7 @@ func (chain *ChainSubmodule) API() v1api.IChain { IActor: NewActorAPI(chain), IChainInfo: NewChainInfoAPI(chain), IMinerState: NewMinerStateAPI(chain), + IBeacon: NewBeaconAPI(chain), } }