Skip to content

Commit 0c0742e

Browse files
authored
fix: impl api BeaconGetEntry (#4989)
1 parent 6c31def commit 0c0742e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

app/submodule/chain/beacon.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package chain
2+
3+
import (
4+
"context"
5+
6+
"github.com/filecoin-project/go-state-types/abi"
7+
v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1"
8+
"github.com/filecoin-project/venus/venus-shared/types"
9+
)
10+
11+
var _ v1api.IBeacon = &beaconAPI{}
12+
13+
type beaconAPI struct {
14+
chain *ChainSubmodule
15+
}
16+
17+
//NewBeaconAPI create a new beacon api
18+
func NewBeaconAPI(chain *ChainSubmodule) v1api.IBeacon {
19+
return &beaconAPI{chain: chain}
20+
}
21+
22+
// BeaconGetEntry returns the beacon entry for the given filecoin epoch. If
23+
// the entry has not yet been produced, the call will block until the entry
24+
// becomes available
25+
func (beaconAPI *beaconAPI) BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) {
26+
return beaconAPI.chain.API().StateGetBeaconEntry(ctx, epoch)
27+
}

app/submodule/chain/chain_submodule.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func (chain *ChainSubmodule) API() v1api.IChain {
113113
IActor: NewActorAPI(chain),
114114
IChainInfo: NewChainInfoAPI(chain),
115115
IMinerState: NewMinerStateAPI(chain),
116+
IBeacon: NewBeaconAPI(chain),
116117
}
117118
}
118119

0 commit comments

Comments
 (0)