// Finalize inherits security scheme and action responses from parent and top level design.
423182
func (a *ActionDefinition) Finalize() {
	// Inherit security scheme
	if a.Security == nil {
		a.Security = a.Parent.Security // ResourceDefinition
		if a.Security == nil {
			a.Security = Design.Security
		}
	}

	if a.Security != nil && a.Security.Scheme.Kind == NoSecurityKind {
		a.Security = nil
	}

	if a.Payload != nil {
		a.Payload.Finalize()
	}

	a.mergeResponses()
	a.initImplicitParams()
	a.initQueryParams()
}
984803
func (ssa *SQLStorageAuthority) FinalizeAuthorization(ctx context.Context, authz core.Authorization) error {
	tx, err := ssa.dbMap.Begin()
	if err != nil {
		return err
	}
	txWithCtx := tx.WithContext(ctx)

	// Check that a pending authz exists
	if !existingPending(txWithCtx, authz.ID) {
		err = berrors.NotFoundError("authorization with ID %q not found", authz.ID)
		return Rollback(tx, err)
	}
	if statusIsPending(authz.Status) {
		err = berrors.InternalServerError("authorization to finalize is pending (ID %q)", authz.ID)
		return Rollback(tx, err)
	}

	auth := &authzModel{authz}
	pa, err := selectPendingAuthz(txWithCtx, "WHERE id = ?", authz.ID)
	if err == sql.ErrNoRows {
		return Rollback(tx, berrors.NotFoundError("authorization with ID %q not found", authz.ID))
	}
	if err != nil {
		return Rollback(tx, err)
	}

	err = txWithCtx.Insert(auth)
	if err != nil {
		return Rollback(tx, err)
	}

	_, err = txWithCtx.Delete(pa)
	if err != nil {
		return Rollback(tx, err)
	}

	err = updateChallenges(txWithCtx, authz.ID, authz.Challenges)
	if err != nil {
		return Rollback(tx, err)
	}

	return tx.Commit()
}
1308662
func (fbo *folderBranchOps) finalizeResolution(ctx context.Context,
	lState *kbfssync.LockState, md *RootMetadata, bps blockPutState,
	newOps []op, blocksToDelete []kbfsblock.ID) error {
	// Take the writer lock.
	fbo.mdWriterLock.Lock(lState)
	defer fbo.mdWriterLock.Unlock(lState)
	return fbo.finalizeResolutionLocked(
		ctx, lState, md, bps, newOps, blocksToDelete)
}
158905
func (c *Class) Finalize(rateLimit uint) {
	if rateLimit == 0 {
		rateLimit = 1
	}
	c.TotalQueries = (c.TotalQueries * rateLimit) + c.outliers
	c.Metrics.Finalize(rateLimit, c.TotalQueries)
	if c.Example.QueryTime == 0 {
		c.Example = nil
	}
}
722366
func (s Status) Final() bool {
	switch s {
	case StatusSucceeded, StatusFailed, StatusOverrun, StatusAborted:
		return true
	default:
		return false
	}
}
926706
func (c *cache) finalizer() {
	if c.mmap != nil {
		c.mmap.Unmap()
		c.dump.Close()
		c.mmap, c.dump = nil, nil
	}
}
528125
func (d *namespacedResourcesDeleter) finalizeNamespace(namespace *v1.Namespace) (*v1.Namespace, error) {
	namespaceFinalize := v1.Namespace{}
	namespaceFinalize.ObjectMeta = namespace.ObjectMeta
	namespaceFinalize.Spec = namespace.Spec
	finalizerSet := sets.NewString()
	for i := range namespace.Spec.Finalizers {
		if namespace.Spec.Finalizers[i] != d.finalizerToken {
			finalizerSet.Insert(string(namespace.Spec.Finalizers[i]))
		}
	}
	namespaceFinalize.Spec.Finalizers = make([]v1.FinalizerName, 0, len(finalizerSet))
	for _, value := range finalizerSet.List() {
		namespaceFinalize.Spec.Finalizers = append(namespaceFinalize.Spec.Finalizers, v1.FinalizerName(value))
	}
	namespace, err := d.nsClient.Finalize(&namespaceFinalize)
	if err != nil {
		// it was removed already, so life is good
		if errors.IsNotFound(err) {
			return namespace, nil
		}
	}
	return namespace, err
}
102692
func Finalize(bundle Bundle) (Bundle, error) {
	var valueTrits = make([]Trits, len(bundle))
	var timestampTrits = make([]Trits, len(bundle))
	var currentIndexTrits = make([]Trits, len(bundle))
	var obsoleteTagTrits = make([]Trits, len(bundle))
	var lastIndexTrits = PadTrits(IntToTrits(int64(bundle[0].LastIndex)), 27)

	for i := range bundle {
		valueTrits[i] = PadTrits(IntToTrits(bundle[i].Value), 81)
		timestampTrits[i] = PadTrits(IntToTrits(int64(bundle[i].Timestamp)), 27)
		currentIndexTrits[i] = PadTrits(IntToTrits(int64(bundle[i].CurrentIndex)), 27)
		obsoleteTagTrits[i] = PadTrits(MustTrytesToTrits(bundle[i].ObsoleteTag), 81)
	}

	var bundleHash Hash
	for {
		k := kerl.NewKerl()

		for i := 0; i < len(bundle); i++ {
			relevantTritsForBundleHash := MustTrytesToTrits(
				bundle[i].Address +
					MustTritsToTrytes(valueTrits[i]) +
					MustTritsToTrytes(obsoleteTagTrits[i]) +
					MustTritsToTrytes(timestampTrits[i]) +
					MustTritsToTrytes(currentIndexTrits[i]) +
					MustTritsToTrytes(lastIndexTrits),
			)
			k.Absorb(relevantTritsForBundleHash)
		}

		bundleHashTrits, err := k.Squeeze(HashTrinarySize)
		if err != nil {
			return nil, err
		}
		bundleHash = MustTritsToTrytes(bundleHashTrits)

		// check whether normalized bundle hash can be computed
		normalizedBundleHash := signing.NormalizedBundleHash(bundleHash)
		ok := true
		for i := range normalizedBundleHash {
			if normalizedBundleHash[i] == 13 {
				ok = false
				break
			}
		}
		if ok {
			break
		}
		obsoleteTagTrits[0] = AddTrits(obsoleteTagTrits[0], Trits{1})
	}

	// set the computed bundle hash on each tx in the bundle
	for i := range bundle {
		tx := &bundle[i]
		if i == 0 {
			tx.ObsoleteTag = MustTritsToTrytes(obsoleteTagTrits[0])
		}
		tx.Bundle = bundleHash
	}

	return bundle, nil
}
596350
func (megaPi *Adaptor) Finalize() error {
	megaPi.finalizeChannel <- struct{}{}
	<-megaPi.finalizeChannel
	if err := megaPi.connection.Close(); err != nil {
		return err
	}
	return nil
}
36792
func (l SecondaryLayer) Finalize() {
	l.lock.Lock()
	e, err := l.store.SeekFirst()
	if err != io.EOF {
		_, v, err := e.Next()
		for err != io.EOF {
			if v != nil {
				v.Finalize()
			}
			_, v, err = e.Next()
		}
		e.Close()
	}
	l.lock.Unlock()
}
990610
func (e *Adaptor) Finalize() (err error) {
	if errs := e.tristate.Unexport(); errs != nil {
		err = multierror.Append(err, errs)
	}
	for _, pin := range e.digitalPins {
		if pin != nil {
			if errs := pin.Unexport(); errs != nil {
				err = multierror.Append(err, errs)
			}
		}
	}
	for _, pin := range e.pwmPins {
		if pin != nil {
			if errs := pin.Enable(false); errs != nil {
				err = multierror.Append(err, errs)
			}
			if errs := pin.Unexport(); errs != nil {
				err = multierror.Append(err, errs)
			}
		}
	}
	if e.i2cBus != nil {
		if errs := e.i2cBus.Close(); errs != nil {
			err = multierror.Append(err, errs)
		}
	}
	return
}
794268
func (c *Clique) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
	// No block rewards in PoA, so the state remains as is and uncles are dropped
	header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
	header.UncleHash = types.CalcUncleHash(nil)

	// Assemble and return the final block for sealing
	return types.NewBlock(header, txs, nil, receipts), nil
}
725655
func (g *graph) Finalize() {
	for _, def := range g.definitions {
		def.Obscure(g)
	}
}
994390
func (p *environProvider) FinalizeCloud(
	ctx environs.FinalizeCloudContext,
	in cloud.Cloud,
) (cloud.Cloud, error) {
	var endpoint string
	resolveEndpoint := func(name string, ep *string) error {
		// If the name doesn't equal "localhost" then we shouldn't resolve
		// the end point, instead we should just accept what we already have.
		if name != lxdnames.DefaultCloud || *ep != "" {
			return nil
		}
		if endpoint == "" {
			// The cloud endpoint is empty, which means
			// that we should connect to the local LXD.
			hostAddress, err := p.getLocalHostAddress(ctx)
			if err != nil {
				return errors.Trace(err)
			}
			endpoint = hostAddress
		}
		*ep = endpoint
		return nil
	}

	// If any of the endpoints point to localhost, go through and backfill the
	// cloud spec with local host addresses.
	if err := resolveEndpoint(in.Name, &in.Endpoint); err != nil {
		return cloud.Cloud{}, errors.Trace(err)
	}
	for i, k := range in.Regions {
		if err := resolveEndpoint(k.Name, &in.Regions[i].Endpoint); err != nil {
			return cloud.Cloud{}, errors.Trace(err)
		}
	}
	// If the provider type is not named localhost and there is no region, set the
	// region to be a default region
	if in.Name != lxdnames.DefaultCloud && len(in.Regions) == 0 {
		in.Regions = append(in.Regions, cloud.Region{
			Name:     lxdnames.DefaultRemoteRegion,
			Endpoint: in.Endpoint,
		})
	}
	return in, nil
}
422896
func (ut *UploadTracker) Finalize(isolatedPath string) (IsolatedSummary, error) {
	isolFile, err := newIsolatedFile(ut.isol, isolatedPath)
	if err != nil {
		return IsolatedSummary{}, err
	}

	// Check and upload isolate JSON.
	ut.checker.AddItem(isolFile.item(ut.checker.Hash()), true, func(item *Item, ps *isolatedclient.PushState) {
		if ps == nil {
			return
		}
		log.Printf("QUEUED %q for upload", item.RelPath)
		ut.uploader.UploadBytes(item.RelPath, isolFile.contents(), ps, func() {
			log.Printf("UPLOADED %q", item.RelPath)
		})
	})

	// Write the isolated file...
	if isolFile.path != "" {
		if err := isolFile.writeJSONFile(ut.lOS); err != nil {
			return IsolatedSummary{}, err
		}
	}

	return IsolatedSummary{
		Name:   isolFile.name(),
		Digest: isolFile.item(ut.checker.Hash()).Digest,
	}, nil
}
595642
func Finalize(hash uint32, length int32) uint32 {
	hash ^= uint32(length)
	hash ^= hash >> 16
	hash *= 0x85ebca6b
	hash ^= hash >> 13
	hash *= 0xc2b2ae35
	hash ^= hash >> 16
	return hash
}
1343985
func (f *FileServerDefinition) Finalize() {
	// Make sure request path starts with a "/" so codegen can rely on it.
	if !strings.HasPrefix(f.RequestPath, "/") {
		f.RequestPath = "/" + f.RequestPath
	}
	// Inherit security
	if f.Security == nil {
		f.Security = f.Parent.Security // ResourceDefinition
		if f.Security == nil {
			f.Security = Design.Security
		}
	}
	if f.Security != nil && f.Security.Scheme.Kind == NoSecurityKind {
		f.Security = nil
	}
}