// PrepareForExpiringKeys implements function in the interface 'PurgeMgr'
508335
func (p *purgeMgr) PrepareForExpiringKeys(expiringAtBlk uint64) {
	p.waitGrp.Add(1)
	go func() {
		p.lock.Lock()
		p.waitGrp.Done()
		defer p.lock.Unlock()
		p.workingset = p.prepareWorkingsetFor(expiringAtBlk)
	}()
	p.waitGrp.Wait()
}
526210
func (r *EmptyResource) SetExpiry(expires time.Time) {
	r.Metadata.SetExpiry(expires)
}
404810
func (a *API) PrepareRestore() error {
	info := a.backend.RestoreInfo()
	logger.Infof("entering restore preparation mode")
	return info.SetStatus(state.RestorePending)
}
85034
func ExecutionKeyFromID(c context.Context, eid *dm.Execution_ID) *ds.Key {
	return ds.MakeKey(c, "Attempt", eid.AttemptID().DMEncoded(), "Execution", eid.Id)
}
332888
func (s *PerUserKeyring) PrepareBoxesForDevices(m MetaContext, contents PerUserKeySeed,
	generation keybase1.PerUserKeyGeneration, receiverKeys []NaclDHKeyPair,
	senderKey GenericKey) (boxes []keybase1.PerUserKeyBox, err error) {
	// Do not lock self because we do not use self.

	if contents.IsBlank() {
		return nil, errors.New("attempt to box blank per-user-key")
	}

	senderKeyDH, ok := senderKey.(NaclDHKeyPair)
	if !ok {
		return nil, fmt.Errorf("Unexpected encryption key type: %T", senderKey)
	}

	for _, receiverKey := range receiverKeys {
		box, err := NewPerUserKeyBox(contents, receiverKey, senderKeyDH, generation)
		if err != nil {
			return nil, err
		}
		boxes = append(boxes, box)
	}
	return boxes, nil
}
341981
func registerPreKeys() error {
	body, err := json.MarshalIndent(preKeys, "", "")
	if err != nil {
		return err
	}

	resp, err := transport.putJSON(prekeyMetadataPath, body)
	if err != nil {
		return err
	}
	if resp.isError() {
		return resp
	}
	return nil
}
1050563
func (s Strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
	ism := obj.(*imageapi.ImageStreamMapping)
	if len(ism.Image.DockerImageReference) == 0 {
		internalRegistry, ok := s.registryHostRetriever.InternalRegistryHostname()
		if ok {
			ism.Image.DockerImageReference = imageapi.DockerImageReference{
				Registry:  internalRegistry,
				Namespace: ism.Namespace,
				Name:      ism.Name,
				ID:        ism.Image.Name,
			}.Exact()
		}
	}

	// signatures can be added using "images" or "imagesignatures" resources
	ism.Image.Signatures = nil
}
206590
func (s *CreateTrailInput) SetS3KeyPrefix(v string) *CreateTrailInput {
	s.S3KeyPrefix = &v
	return s
}
430887
func (s *LoggingStatus) SetS3KeyPrefix(v string) *LoggingStatus {
	s.S3KeyPrefix = &v
	return s
}
192220
func DelKeyWithPrefix(rm kv.RetrieverMutator, prefix kv.Key) error {
	var keys []kv.Key
	iter, err := rm.Iter(prefix, prefix.PrefixNext())
	if err != nil {
		return errors.Trace(err)
	}

	defer iter.Close()
	for {
		if err != nil {
			return errors.Trace(err)
		}

		if iter.Valid() && iter.Key().HasPrefix(prefix) {
			keys = append(keys, iter.Key().Clone())
			err = iter.Next()
			if err != nil {
				return errors.Trace(err)
			}
		} else {
			break
		}
	}

	for _, key := range keys {
		err := rm.Delete(key)
		if err != nil {
			return errors.Trace(err)
		}
	}

	return nil
}
792447
func (c *Client) execWithKeys(urp bool, cmd string, keys []string, a ...interface{}) ([]interface{}, error) {
	var v []interface{}
	for _, k := range keys {
		tmp, err := c.execWithKey(urp, cmd, k, a...)
		if err != nil {
			return nil, err
		}
		v = append(v, tmp)
	}
	return v, nil
}
1262739
func processKeys(keys map[rune]kb.Key) ([]byte, []byte, error) {
	// order rune keys
	idx := make([]rune, len(keys))
	var i int
	for c := range keys {
		idx[i] = c
		i++
	}
	sort.Slice(idx, func(a, b int) bool {
		return idx[a] < idx[b]
	})

	// process
	var constBuf, mapBuf bytes.Buffer
	for _, c := range idx {
		key := keys[c]

		g, isGoCode := goCodes[c]
		s := fmt.Sprintf("\\u%04x", c)
		if isGoCode {
			s = g
		} else if key.Print {
			s = fmt.Sprintf("%c", c)
		}

		// add key definition
		v := strings.TrimPrefix(fmt.Sprintf("%#v", key), "kb.")
		v = nameRE.ReplaceAllString(v, "")
		mapBuf.WriteString(fmt.Sprintf("'%s': &%s,\n", s, v))

		// fix 'Quote' const
		if s == `\'` {
			s = `'`
		}

		// add const definition
		if (isGoCode && c != '\n') || !key.Print {
			n := strings.TrimPrefix(key.Key, ".")
			if n == `'` || n == `\` {
				n = key.Code
			}

			constBuf.WriteString(fmt.Sprintf("%s = \"%s\"\n", n, s))
		}
	}

	return constBuf.Bytes(), mapBuf.Bytes(), nil
}
498718
func (n *Namespace) SetExpiry(expires time.Time) {
	n.Metadata.SetExpiry(expires)
}
291929
func (a *Account) MaxAutoExpireResponseMaps() int {
	a.mu.RLock()
	defer a.mu.RUnlock()
	return int(a.maxnae)
}
196844
func (s *Condition) SetKeyPrefixEquals(v string) *Condition {
	s.KeyPrefixEquals = &v
	return s
}
929817
func (c *DNSCache) ForceExpireByNames(expireLookupsBefore time.Time, names []string) (namesAffected []string) {
	c.Lock()
	defer c.Unlock()
	for _, name := range names {
		entries, exists := c.forward[name]
		if !exists {
			continue
		}

		// We pass expireLookupsBefore as the `now` parameter but it is redundant
		// because LookupTime must be before ExpirationTime.
		// The second expireLookupsBefore actually matches lookup times, and will
		// delete the entries completely.
		nameNeedsRegen := c.removeExpired(entries, expireLookupsBefore, expireLookupsBefore)
		if nameNeedsRegen {
			namesAffected = append(namesAffected, name)
		}
	}

	return namesAffected
}
366845
func (d *DiskStorer) ResetExpiry(key string) error {
	if !validKey(key) {
		return errNoSession{}
	}

	filePath := path.Join(d.folderPath, key)
	nowTime := time.Now().UTC()

	return os.Chtimes(filePath, nowTime, nowTime)
}