// TxPowerLevel returns the tx power level of the remote peripheral.
510046
func (a *Advertisement) TxPowerLevel() int {
	pwr, _ := a.packets().TxPower()
	return pwr
}
1208821
func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
	if !c.connectionGood {
		return nil, driver.ErrBadConn
	}
	if opts.ReadOnly {
		return nil, errors.New("Read-only transactions are not supported")
	}

	var tdsIsolation isoLevel
	switch sql.IsolationLevel(opts.Isolation) {
	case sql.LevelDefault:
		tdsIsolation = isolationUseCurrent
	case sql.LevelReadUncommitted:
		tdsIsolation = isolationReadUncommited
	case sql.LevelReadCommitted:
		tdsIsolation = isolationReadCommited
	case sql.LevelWriteCommitted:
		return nil, errors.New("LevelWriteCommitted isolation level is not supported")
	case sql.LevelRepeatableRead:
		tdsIsolation = isolationRepeatableRead
	case sql.LevelSnapshot:
		tdsIsolation = isolationSnapshot
	case sql.LevelSerializable:
		tdsIsolation = isolationSerializable
	case sql.LevelLinearizable:
		return nil, errors.New("LevelLinearizable isolation level is not supported")
	default:
		return nil, errors.New("Isolation level is not supported or unknown")
	}
	return c.begin(ctx, tdsIsolation)
}
103815
func power2(x uint) uint {
	x--
	x |= x >> 1
	x |= x >> 2
	x |= x >> 4
	x |= x >> 8
	x |= x >> 16
	x |= x >> 32
	x++
	return x
}
546529
func GetPowerInfo() (int, int, int) {
	_secs := C.int(0)
	_percent := C.int(0)
	_state := C.SDL_GetPowerInfo(&_secs, &_percent)
	return (int)(_state), (int)(_secs), (int)(_percent)
}
194862
func (vc *Bucket) Power(id crypto.Address) (*big.Int, error) {
	return vc.Previous.Power(id)
}
1176249
func TxPaysToAddress(msgTx *wire.MsgTx, addr string,
	params *chaincfg.Params) (outpoints []*wire.OutPoint) {
	// Check the addresses associated with the PkScript of each TxOut
	txTree := TxTree(msgTx)
	hash := msgTx.TxHash()
	for outIndex, txOut := range msgTx.TxOut {
		_, txOutAddrs, _, err := txscript.ExtractPkScriptAddrs(txOut.Version,
			txOut.PkScript, params)
		if err != nil {
			fmt.Printf("ExtractPkScriptAddrs: %v", err.Error())
			continue
		}

		// Check if we are watching any address for this TxOut
		for _, txAddr := range txOutAddrs {
			addrstr := txAddr.EncodeAddress()
			if addr == addrstr {
				outpoints = append(outpoints, wire.NewOutPoint(&hash,
					uint32(outIndex), txTree))
			}
		}
	}
	return
}
491512
func (n *notaryCommander) setVerbosityLevel() {
	if n.debug {
		logrus.SetLevel(logrus.DebugLevel)
	} else if n.verbose {
		logrus.SetLevel(logrus.InfoLevel)
	} else {
		logrus.SetLevel(logrus.WarnLevel)
	}
	logrus.SetOutput(os.Stderr)
}
181972
func (b *Driver) SetTXPower(level int) (err error) {
	buf := []byte{byte(level)}

	err = b.adaptor().WriteCharacteristic(txPowerCharacteristic, buf)
	if err != nil {
		fmt.Println("SetTXLevel error:", err)
		return err
	}

	return
}
118843
func (h *ADXL345Driver) UseLowPower(power bool) (err error) {
	if power {
		h.bwRate.lowPower = 1
	} else {
		h.bwRate.lowPower = 0
	}
	if _, err := h.connection.Write([]byte{ADXL345_REG_BW_RATE, h.bwRate.toByte()}); err != nil {
		return err
	}
	return
}
185985
func SetLevel(r, g, b byte, w io.Writer) error {
	return write(w, []byte{0x31, r, g, b, 0x00, 0xf0, 0x0f})
}
383083
func txPQByPriority(pq *txPriorityQueue, i, j int) bool {
	// Using > here so that pop gives the highest priority item as opposed
	// to the lowest.  Sort by priority first, then fee.
	if pq.items[i].priority == pq.items[j].priority {
		return pq.items[i].feePerKB > pq.items[j].feePerKB
	}
	return pq.items[i].priority > pq.items[j].priority

}
819073
func NewLowlevel(db *leveldb.DB, location string) *Lowlevel {
	return &Lowlevel{
		DB:        db,
		location:  location,
		folderIdx: newSmallIndex(db, []byte{KeyTypeFolderIdx}),
		deviceIdx: newSmallIndex(db, []byte{KeyTypeDeviceIdx}),
		closeMut:  &sync.RWMutex{},
	}
}
380179
func SetLevel(threshold Level, c Collector) {
	cfg.lock()
	defer cfg.unlock()

	new := cfg.get().clone()
	entry, present := new.registry[c]
	if !present {
		return
	}
	entry.threshold = threshold
	new.updateThreshold()
	cfg.set(new)
}
1307986
func SetLevel(c context.Context, l Level) context.Context {
	return context.WithValue(c, levelKey, l)
}
729075
func (iapi *InsightApi) TxConverter(txs []*dcrjson.TxRawResult) ([]apitypes.InsightTx, error) {
	return iapi.DcrToInsightTxns(txs, false, false, false)
}
821926
func (d Device) AveragePowerUsage(since time.Duration) (uint, error) {
	if C.nvmlHandle == nil {
		return 0, errLibraryNotLoaded
	}
	lastTs := C.ulonglong(time.Now().Add(-1*since).UnixNano() / 1000)
	var n C.uint
	r := C.nvmlDeviceGetAverageUsage(d.dev, C.NVML_TOTAL_POWER_SAMPLES, lastTs, &n)
	return uint(n), errorString(r)
}
1283119
func NextPowerOf2(x int) int {
	if IsPowerOf2(x) {
		return x
	}

	return int(math.Pow(2, math.Ceil(math.Log2(float64(x)))))
}