// NewFakeDelayer creates a ethash consensus engine with a fake PoW scheme that
// accepts all blocks as valid, but delays verifications by some time, though
// they still have to conform to the Ethereum consensus rules.
343689
func NewFakeDelayer(delay time.Duration) *Ethash {
	return &Ethash{
		config: Config{
			PowMode: ModeFake,
		},
		fakeDelay: delay,
	}
}
771469
func NewLedgerCommitter(ledger PeerLedgerSupport) *LedgerCommitter {
	return NewLedgerCommitterReactive(ledger, func(_ *common.Block) error { return nil })
}
1335661
func NewAuthenticator(ca tlsgen.CA) *Authenticator {
	return &Authenticator{
		mapper: newCertMapper(ca.NewClientCertKeyPair),
	}
}
1274053
func NewFakeClusterLister(resp *container.ListClustersResponse, err error) *FakeClusterLister {
	return &FakeClusterLister{
		Resp: resp,
		Err:  err,
	}
}
127464
func newExponentialDelayer(joiner string, opts *delayOpts) (*exponentialDelayer, error) {
	if opts == nil {
		opts = newDelayOpts()
	}

	randomizer := opts.randomizer
	if randomizer == nil {
		randomizer = defaultRandomizer
	}

	sleeper := opts.sleeper
	if sleeper == nil {
		sleeper = defaultSleeper
	}

	return &exponentialDelayer{
		logger:          logging.Logger("join").WithField("local", joiner),
		initialDelay:    opts.initial,
		nextDelayMin:    0,
		maxDelayReached: false,
		maxDelay:        opts.max,
		randomizer:      randomizer,
		sleeper:         sleeper,
		numDelays:       0,
	}, nil
}
776844
func (_m *BlockVerifier) VerifyBlockSignature(sd []*common.SignedData, config *common.ConfigEnvelope) error {
	ret := _m.Called(sd, config)

	var r0 error
	if rf, ok := ret.Get(0).(func([]*common.SignedData, *common.ConfigEnvelope) error); ok {
		r0 = rf(sd, config)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
243983
func NewFakeResponseWriter(buffer io.Writer) *FakeResponseWriter {
	return &FakeResponseWriter{
		header: http.Header{},
		buffer: buffer,
	}
}
412321
func newAsyncIDTokenVerifier(ctx context.Context, c *oidc.Config, iss string) *asyncIDTokenVerifier {
	t := &asyncIDTokenVerifier{}

	sync := make(chan struct{})
	// Polls indefinitely in an attempt to initialize the distributed claims
	// verifier, or until context canceled.
	initFn := func() (done bool, err error) {
		klog.V(4).Infof("oidc authenticator: attempting init: iss=%v", iss)
		v, err := initVerifier(ctx, c, iss)
		if err != nil {
			klog.Errorf("oidc authenticator: async token verifier for issuer: %q: %v", iss, err)
			return false, nil
		}
		t.m.Lock()
		defer t.m.Unlock()
		t.v = v
		close(sync)
		return true, nil
	}

	go func() {
		if done, _ := initFn(); !done {
			go wait.PollUntil(time.Second*10, initFn, ctx.Done())
		}
	}()

	if synchronizeTokenIDVerifierForTest {
		<-sync
	}

	return t
}
1145199
func NewFakeS3Context(ctx context.Context) context.Context {
	return context.WithValue(ctx, fakeS3Key, true)
}
516095
func NewFromHash(hashedKey string) (Crypter, error) {
	var f func() Crypter

	if strings.HasPrefix(hashedKey, cryptPrefixes[SHA512]) {
		f = crypts[SHA512]
	} else if strings.HasPrefix(hashedKey, cryptPrefixes[SHA256]) {
		f = crypts[SHA256]
	} else if strings.HasPrefix(hashedKey, cryptPrefixes[MD5]) {
		f = crypts[MD5]
	} else if strings.HasPrefix(hashedKey, cryptPrefixes[APR1]) {
		f = crypts[APR1]
	}

	if f != nil {
		return f(), nil
	}

	return nil, errors.New("Invalid hash")
}
1271927
func NewFakeMysqlDaemon(db *fakesqldb.DB) *FakeMysqlDaemon {
	result := &FakeMysqlDaemon{
		db:      db,
		Running: true,
	}
	if db != nil {
		result.appPool = dbconnpool.NewConnectionPool("AppConnPool", 5, time.Minute, 0)
		result.appPool.Open(db.ConnParams(), stats.NewTimings("", "", ""))
	}
	return result
}
1296360
func (p *Provider) Verifier(config *Config) *IDTokenVerifier {
	return NewVerifier(p.issuer, p.remoteKeySet, config)
}
1012291
func NewVerificationEngine(context string) (VerificationEngine, error) {

	engine := VerificationEngine{}

	if context == "" {
		return engine, errors.New("Context cannot be empty when initializing the Verification Engine")
	}

	// try to load the public key and if it succeed, then return both the keys
	publicFile := fmt.Sprintf(publicKeySuffixFormat, sanitizeIdentifier(context))
	// if the key exists
	if keyFileExists(publicFile) {
		// try to read it
		public, err := readKey(publicFile, keysFolderPrefixFormat)
		if err != nil {
			// in case of error return it
			return engine, err
		}

		// if we reached here, it means that both the public key
		// existed and was loaded successfull
		engine.publicKey = public
	}

	return engine, nil

}
720401
func New224() hash.Hash {
	d := new(digest)
	d.is224 = true
	d.Reset()
	return d
}
893002
func newPyEthereumGenesisSpec(network string, genesis *core.Genesis) (*pyEthereumGenesisSpec, error) {
	// Only ethash is currently supported between go-ethereum and pyethereum
	if genesis.Config.Ethash == nil {
		return nil, errors.New("unsupported consensus engine")
	}
	spec := &pyEthereumGenesisSpec{
		Timestamp:  (hexutil.Uint64)(genesis.Timestamp),
		ExtraData:  genesis.ExtraData,
		GasLimit:   (hexutil.Uint64)(genesis.GasLimit),
		Difficulty: (*hexutil.Big)(genesis.Difficulty),
		Mixhash:    genesis.Mixhash,
		Coinbase:   genesis.Coinbase,
		Alloc:      genesis.Alloc,
		ParentHash: genesis.ParentHash,
	}
	spec.Nonce = (hexutil.Bytes)(make([]byte, 8))
	binary.LittleEndian.PutUint64(spec.Nonce[:], genesis.Nonce)

	return spec, nil
}
413915
func NewBlockValidator(config *params.ChainConfig, blockchain *BlockChain, engine consensus.Engine) *BlockValidator {
	validator := &BlockValidator{
		config: config,
		engine: engine,
		bc:     blockchain,
	}
	return validator
}
969840
func (p *Provider) NewVerifier(ctx context.Context, options ...VerificationOption) *IDTokenVerifier {
	return &IDTokenVerifier{
		issuer:  p.Issuer,
		keySet:  newRemoteKeySet(ctx, p.JWKSURL),
		options: options,
	}
}