// incBytesReceived increases the number of received bytes atomically be the
// specified number.
494621
func (m Metrics) incBytesReceived(delta uint64) {
	atomic.AddUint64(m.BytesReceived, delta)
}
401253
func getReceivedByAccount(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
	cmd := icmd.(*btcjson.GetReceivedByAccountCmd)

	account, err := w.AccountNumber(waddrmgr.KeyScopeBIP0044, cmd.Account)
	if err != nil {
		return nil, err
	}

	// TODO: This is more inefficient that it could be, but the entire
	// algorithm is already dominated by reading every transaction in the
	// wallet's history.
	results, err := w.TotalReceivedForAccounts(
		waddrmgr.KeyScopeBIP0044, int32(*cmd.MinConf),
	)
	if err != nil {
		return nil, err
	}
	acctIndex := int(account)
	if account == waddrmgr.ImportedAddrAccount {
		acctIndex = len(results) - 1
	}
	return results[acctIndex].TotalReceived.ToBTC(), nil
}
62156
func (c *i2cConnection) ReadByte() (val byte, err error) {
	c.mutex.Lock()
	defer c.mutex.Unlock()

	if err := c.bus.SetAddress(c.address); err != nil {
		return 0, err
	}
	return c.bus.ReadByte()
}
1268173
func MessageFromBytes(msgBytes []byte) (msg RFC2822Message, err error) {
	// The header and body are separated by a double new-line
	splitMessage := bytes.SplitN(msgBytes, []byte("\r\n\r\n"), 2)

	// Read the headers
	headerReader := textproto.NewReader(bufio.NewReader(bytes.NewReader(splitMessage[0])))
	msg.Headers, err = headerReader.ReadMIMEHeader()

	if err != nil && err != io.EOF {
		return msg, err
	}

	if len(splitMessage) == 2 {
		msg.Body = string(splitMessage[1])
	}

	return msg, nil
}
1172868
func (s *Transport) WaitReceiveChannel() (libchan.Receiver, error) {
	r, ok := <-s.receiverChan
	if !ok {
		return nil, io.EOF
	}

	return r, nil
}
111539
func (s *EstimatedResourceSize) SetEstimatedSizeInBytes(v float64) *EstimatedResourceSize {
	s.EstimatedSizeInBytes = &v
	return s
}
148400
func (c *CountingReader) ReadByte() (byte, error) {
	// If our underlying reader is a ByteReader, use its ReadByte directly.
	if br, ok := c.Reader.(io.ByteReader); ok {
		b, err := br.ReadByte()
		if err == nil {
			c.Count++
		}
		return b, err
	}

	data := []byte{0}
	amount, err := c.Reader.Read(data)
	if amount != 0 {
		c.Count += int64(amount)
		return data[0], err
	}
	return 0, err
}
818866
func (m *MockReceivedPacketHandler) ReceivedPacket(arg0 protocol.PacketNumber, arg1 protocol.EncryptionLevel, arg2 time.Time, arg3 bool) error {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "ReceivedPacket", arg0, arg1, arg2, arg3)
	ret0, _ := ret[0].(error)
	return ret0
}
262271
func ShouldEventuallyReceive(t testing.TB, c interface{}, timeouts ...time.Duration) interface{} {
	t.Helper()
	if !isChan(c) {
		t.Fatal("ShouldEventuallyReceive c argument should be a channel")
	}
	v := reflect.ValueOf(c)

	timeout := time.After(500 * time.Millisecond)

	if len(timeouts) > 0 {
		timeout = time.After(timeouts[0])
	}

	recvChan := make(chan reflect.Value)

	go func() {
		v, ok := v.Recv()
		if ok {
			recvChan <- v
		}
	}()

	select {
	case <-timeout:
		t.Fatal(errors.New("timed out waiting for channel to receive"))
	case a := <-recvChan:
		return a.Interface()
	}

	return nil
}
785468
func NewReceivedPacketHandler(
	rttStats *congestion.RTTStats,
	logger utils.Logger,
	version protocol.VersionNumber,
) ReceivedPacketHandler {
	return &receivedPacketHandler{
		initialPackets:   newReceivedPacketTracker(rttStats, logger, version),
		handshakePackets: newReceivedPacketTracker(rttStats, logger, version),
		oneRTTPackets:    newReceivedPacketTracker(rttStats, logger, version),
	}
}
76156
func OnSignalsReceived(signalNames []string, deciders ...Decider) Decider {
	return func(ctx *FSMContext, h *swf.HistoryEvent, data interface{}) Outcome {
		switch *h.EventType {
		case swf.EventTypeWorkflowExecutionSignaled:
			for _, signalName := range signalNames {
				if *h.WorkflowExecutionSignaledEventAttributes.SignalName == signalName {
					logf(ctx, "at=on-signal-received")
					return NewComposedDecider(deciders...)(ctx, h, data)
				}
			}
		}
		return ctx.Pass()
	}
}
93187
func (p *Peer) VerAckReceived() bool {
	p.flagsMtx.Lock()
	verAckReceived := p.verAckReceived
	p.flagsMtx.Unlock()

	return verAckReceived
}
243947
func (s *sender) sendWithRetryAnticipate() (*net.UDPAddr, error) {
	s.retry.reset()
	for {
		addr, err := s.sendDatagramAnticipate()
		if _, ok := err.(net.Error); ok && s.retry.count() < s.retries {
			s.retry.backoff()
			continue
		}
		return addr, err
	}
}
176022
func (s *Slice) ReadByte() (c byte, err error) {
	if len(*s) < 1 {
		return 0, io.EOF
	}

	c = (*s)[0]
	if len(*s) > 1 {
		*s = (*s)[1:]
	} else {
		*s = nil
	}
	return c, nil
}
512876
func handleStopNotifyReceived(wsc *wsClient, icmd interface{}) (interface{}, error) {
	cmd, ok := icmd.(*btcjson.StopNotifyReceivedCmd)
	if !ok {
		return nil, btcjson.ErrRPCInternal
	}

	// Decode addresses to validate input, but the strings slice is used
	// directly if these are all ok.
	err := checkAddressValidity(cmd.Addresses, wsc.server.cfg.ChainParams)
	if err != nil {
		return nil, err
	}

	for _, addr := range cmd.Addresses {
		wsc.server.ntfnMgr.UnregisterTxOutAddressRequest(wsc, addr)
	}

	return nil, nil
}
1065585
func NewReceived(numBlock NumBlock, numChaincode NumChaincode) Received {
	return Received{NumBlock: numBlock, NumChaincode: numChaincode}
}
41219
func (d *Decoder) readBytes(delim byte) (line []byte, err error) {
	line, err = d.r.ReadBytes(delim)
	if d.raw {
		d.buf = append(d.buf, line...)
	}
	d.n += len(line)
	return
}