add missing file
This commit is contained in:
parent
57d57e54a1
commit
32a5c52105
35
node/impl/full/beacon.go
Normal file
35
node/impl/full/beacon.go
Normal file
@ -0,0 +1,35 @@
|
||||
package full
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/beacon"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"go.uber.org/fx"
|
||||
)
|
||||
|
||||
type BeaconAPI struct {
|
||||
fx.In
|
||||
|
||||
Beacon beacon.RandomBeacon
|
||||
}
|
||||
|
||||
func (a *BeaconAPI) BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) {
|
||||
rr := a.Beacon.MaxBeaconRoundForEpoch(epoch, types.BeaconEntry{})
|
||||
e := a.Beacon.Entry(ctx, rr)
|
||||
|
||||
select {
|
||||
case be, ok := <-e:
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("beacon get returned no value")
|
||||
}
|
||||
if be.Err != nil {
|
||||
return nil, be.Err
|
||||
}
|
||||
return &be.Entry, nil
|
||||
case <-ctx.Done():
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user