// SpendHintKey returns the key that will be used to index the spend request's
// hint within the height hint cache.
550396
func (r SpendRequest) SpendHintKey() ([]byte, error) {
	if r.OutPoint == ZeroOutPoint {
		return r.PkScript.Script(), nil
	}

	var outpoint bytes.Buffer
	err := channeldb.WriteElement(&outpoint, r.OutPoint)
	if err != nil {
		return nil, err
	}

	return outpoint.Bytes(), nil
}
761104
func (o *ListOptions) UseCache(key string, ttl time.Duration) {
	o.cacheKey, o.cacheTTL = key, ttl
}
1044924
func (m *mockSpendNotifier) Spend(outpoint *wire.OutPoint, height int32,
	txn *wire.MsgTx) {
	m.mtx.Lock()
	defer m.mtx.Unlock()

	txnHash := txn.TxHash()
	details := &chainntnfs.SpendDetail{
		SpentOutPoint:     outpoint,
		SpendingHeight:    height,
		SpendingTx:        txn,
		SpenderTxHash:     &txnHash,
		SpenderInputIndex: outpoint.Index,
	}

	// Cache details in case of late registration.
	if _, ok := m.spends[*outpoint]; !ok {
		m.spends[*outpoint] = details
	}

	// Deliver any backlogged spend notifications.
	if spendChans, ok := m.spendMap[*outpoint]; ok {
		delete(m.spendMap, *outpoint)
		for _, spendChan := range spendChans {
			spendChan <- &chainntnfs.SpendDetail{
				SpentOutPoint:     details.SpentOutPoint,
				SpendingHeight:    details.SpendingHeight,
				SpendingTx:        details.SpendingTx,
				SpenderTxHash:     details.SpenderTxHash,
				SpenderInputIndex: details.SpenderInputIndex,
			}
		}
	}
}
878472
func (info ClientHelloInfo) Key() string {
	extensions, compressionMethods := "?", "?"
	if !info.ExtensionsUnknown {
		extensions = fmt.Sprintf("%x", info.Extensions)
	}
	if !info.CompressionMethodsUnknown {
		compressionMethods = fmt.Sprintf("%x", info.CompressionMethods)
	}
	return telemetry.FastHash([]byte(fmt.Sprintf("%x-%x-%s-%s-%x-%x",
		info.Version, info.CipherSuites, extensions,
		compressionMethods, info.Curves, info.Points)))
}
212387
func (c *HeightHintCache) QueryConfirmHint(confRequest ConfRequest) (uint32, error) {
	var hint uint32
	err := c.db.View(func(tx *bolt.Tx) error {
		confirmHints := tx.Bucket(confirmHintBucket)
		if confirmHints == nil {
			return ErrCorruptedHeightHintCache
		}

		confHintKey, err := confRequest.ConfHintKey()
		if err != nil {
			return err
		}
		confirmHint := confirmHints.Get(confHintKey)
		if confirmHint == nil {
			return ErrConfirmHintNotFound
		}

		return channeldb.ReadElement(bytes.NewReader(confirmHint), &hint)
	})
	if err != nil {
		return 0, err
	}

	return hint, nil
}
892961
func (ec *EthereumClient) SuggestGasPrice(ctx *Context) (price *BigInt, _ error) {
	rawPrice, err := ec.client.SuggestGasPrice(ctx.context)
	return &BigInt{rawPrice}, err
}
1346281
func AddHintCallback(name string, fn HintCallback, data interface{}) {
	_name := C.CString(name)
	hintCallbacks[name] = HintCallbackAndData{
		callback: fn,
		data:     data,
	}
	C.addHintCallback(_name)
}
1027996
func (c *HeightHintCache) CommitSpendHint(height uint32,
	spendRequests ...SpendRequest) error {

	if len(spendRequests) == 0 {
		return nil
	}

	Log.Tracef("Updating spend hint to height %d for %v", height,
		spendRequests)

	return c.db.Batch(func(tx *bolt.Tx) error {
		spendHints := tx.Bucket(spendHintBucket)
		if spendHints == nil {
			return ErrCorruptedHeightHintCache
		}

		var hint bytes.Buffer
		if err := channeldb.WriteElement(&hint, height); err != nil {
			return err
		}

		for _, spendRequest := range spendRequests {
			spendHintKey, err := spendRequest.SpendHintKey()
			if err != nil {
				return err
			}
			err = spendHints.Put(spendHintKey, hint.Bytes())
			if err != nil {
				return err
			}
		}

		return nil
	})
}
776748
func (s *InputDecryptionSettings) SetEncryptedDecryptionKey(v string) *InputDecryptionSettings {
	s.EncryptedDecryptionKey = &v
	return s
}
665443
func (b *Button) SizeHint() image.Point {
	if len(b.text) == 0 {
		return b.MinSizeHint()
	}

	var size image.Point
	lines := strings.Split(b.text, "\n")
	for _, line := range lines {
		if w := stringWidth(line); w > size.X {
			size.X = w
		}
	}
	size.Y = len(lines)

	return size
}
1078396
func (m ConfigMap) SetKey(key string, value ConfigValue) error {
	if strings.HasPrefix(key, "{topic}.") {
		_, found := m["default.topic.config"]
		if !found {
			m["default.topic.config"] = ConfigMap{}
		}
		m["default.topic.config"].(ConfigMap)[strings.TrimPrefix(key, "{topic}.")] = value
	} else {
		m[key] = value
	}

	return nil
}
618726
func (v *Var) SetKey(value string) {
	// src := []byte(value)
	// regex := regexp.MustCompile("[0-9A-Za-z]+")
	// chunks := regex.FindAll(src, -1)
	// for i, val := range chunks {
	//
	// }
	v.Key = strings.ToUpper(value)
}
977173
func (d *Flow) Hint(options ...FlowHintOption) {
	var config FlowConfig
	for _, option := range options {
		option(&config)
	}
}
472011
func (s Slice) getNthKey(index ValueLength, translate bool) (Slice, error) {
	vpackAssert(s.Type() == Object)

	offset, err := s.getNthOffset(index)
	if err != nil {
		return nil, WithStack(err)
	}
	result := Slice(s[offset:])
	if translate {
		result, err = result.makeKey()
		if err != nil {
			return nil, WithStack(err)
		}
	}
	return result, nil
}
608354
func (s *StoragePacker) BucketKey(itemID string) string {
	return strconv.Itoa(int(s.BucketIndex(itemID)))
}
863345
func RequestCache(c context.Context) *lru.Cache {
	rc, _ := c.Value(&requestCacheKey).(*lru.Cache)
	if rc == nil {
		panic("server/caching: no request cache installed in Context")
	}
	return rc
}
247234
func (api *ServerAPI) SendKey(serverID int64, body *sacloud.KeyboardRequest) (bool, error) {
	var (
		method = "PUT"
		uri    = fmt.Sprintf("%s/%d/keyboard", api.getResourceURL(), serverID)
	)

	return api.modify(method, uri, body)
}