// New will create new witness policy evaluator.
New will create new witness policy evaluator.
// New will create new witness policy evaluator .
func New(configStore storage.Store, policyCacheExpiry time.Duration) (*WitnessPolicy, error) {
	wp := &WitnessPolicy{
		configStore: configStore,
		cacheExpiry: policyCacheExpiry,
		selector:    random.New(),
	}
	wp.cache = gcache.New(defaultCacheSize).ARC().LoaderExpireFunc(wp.loadWitnessPolicy).Build()
	policy, _, err := wp.loadWitnessPolicy(WitnessPolicyKey)
	if err != nil {
		return nil, err
	}
	err = wp.cache.SetWithExpire(WitnessPolicyKey, policy, policyCacheExpiry)
	if err != nil {
		return nil, fmt.Errorf("failed to set expiry entry in policy cache: %w", err)
	}
	logger.Debugf("created new witness policy evaluator with policy: %s "+
		"and witness policy cache expiry period set to: %s", policy, policyCacheExpiry)
	return wp, nil
}
func New ( configStore storage . Store , policyCacheExpiry time . Duration ) ( * WitnessPolicy , error ) { wp := & WitnessPolicy { configStore : configStore , cacheExpiry : policyCacheExpiry , selector : random . New ( ) , } wp . cache = gcache . New ( defaultCacheSize ) . ARC ( ) . LoaderExpireFunc ( wp . loadWitnessPolicy ) . Build ( ) policy , _ , err := wp . loadWitnessPolicy ( WitnessPolicyKey ) if err != nil { return nil , err } err = wp . cache . SetWithExpire ( WitnessPolicyKey , policy , policyCacheExpiry ) if err != nil { return nil , fmt . Errorf ( " " , err ) } logger . Debugf ( " " + " " , policy , policyCacheExpiry ) return wp , nil }
New will create new witness policy evaluator.
New will create new witness policy evaluator .