func New(
	beacon valueProvider,
	atxdb atxProvider,
	meshdb meshProvider,
	vrfVerifier verifierFunc,
	vrfSigner signer,
	layersPerEpoch uint32,
	cfg eCfg.Config,
	logger log.Log) *Oracle {
	vmc, err := lru.New(vrfMsgCacheSize)
	if err != nil {
		logger.With().Panic("could not create lru cache", log.Err(err))
	}
	ac, err := lru.New(activesCacheSize)
	if err != nil {
		logger.With().Panic("could not create lru cache", log.Err(err))
	}
	return &Oracle{
		beacon:         beacon,
		atxdb:          atxdb,
		meshdb:         meshdb,
		vrfVerifier:    vrfVerifier,
		vrfSigner:      vrfSigner,
		layersPerEpoch: layersPerEpoch,
		vrfMsgCache:    vmc,
		activesCache:   ac,
		cfg:            cfg,
		Log:            logger,
	}
}
New returns a new eligibility oracle instance.
package eligibility
import (
	"context"
	"errors"
	"fmt"
	"sync"
	lru "github.com/hashicorp/golang-lru"
	"github.com/spacemeshos/fixed"
	"github.com/spacemeshos/go-spacemesh/common/types"
	eCfg "github.com/spacemeshos/go-spacemesh/hare/eligibility/config"
	"github.com/spacemeshos/go-spacemesh/log"
)
const (
	vrfMsgCacheSize  = 20          
	activesCacheSize = 5           
	maxSupportedN    = 1073741824  
)
type valueProvider interface {
	Value(context.Context, types.EpochID) (uint32, error)
}
type signer interface {
	Sign(msg []byte) []byte
}
type addGet interface {
	Add(key, value interface{}) (evicted bool)
	Get(key interface{}) (value interface{}, ok bool)
}
type atxProvider interface {
	GetMinerWeightsInEpochFromView(targetEpoch types.EpochID, blocks map[types.BlockID]struct{}) (map[string]uint64, error)
	GetEpochAtxs(types.EpochID) ([]types.ATXID, error)
	GetAtxHeader(types.ATXID) (*types.ActivationTxHeader, error)
}
type meshProvider interface {
	LayerContextuallyValidBlocks(context.Context, types.LayerID) (map[types.BlockID]struct{}, error)
}
type verifierFunc = func(pub, msg, sig []byte) bool
type Oracle struct {
	lock           sync.Mutex
	beacon         valueProvider
	atxdb          atxProvider
	meshdb         meshProvider
	vrfSigner      signer
	vrfVerifier    verifierFunc
	layersPerEpoch uint32
	vrfMsgCache    addGet
	activesCache   addGet
	cfg            eCfg.Config
	log.Log
}
func safeLayerRange(
	targetLayer types.LayerID,
	safetyParam,
	layersPerEpoch,
	epochOffset uint32,
) (safeLayerStart, safeLayerEnd types.LayerID) {
	if targetLayer.Uint32() <= safetyParam {
		return types.GetEffectiveGenesis(), types.GetEffectiveGenesis()
	}
	safeLayer := targetLayer.Sub(safetyParam)
	safeEpoch := safeLayer.GetEpoch()
	safeLayerStart = safeEpoch.FirstLayer()
	safeLayerEnd = safeLayerStart.Add(epochOffset)
	if safeLayer.Before(safeLayerEnd) {
		if safeLayerStart.Uint32() <= layersPerEpoch {
			return types.GetEffectiveGenesis(), types.GetEffectiveGenesis()
		}
		safeLayerStart = safeLayerStart.Sub(layersPerEpoch)
		safeLayerEnd = safeLayerEnd.Sub(layersPerEpoch)
	}
	if !safeLayerStart.After(types.GetEffectiveGenesis()) {
		return types.GetEffectiveGenesis(), types.GetEffectiveGenesis()
	}
	return
}