// Append the results from retrieveCoinSupply to the provided ChartData.
// This is the Appender half of a pair that make up a cache.ChartUpdater.
968738
func appendCoinSupply(charts *cache.ChartData, rows *sql.Rows) error {
	defer closeRows(rows)
	blocks := charts.Blocks
	for rows.Next() {
		var value int64
		var timestamp time.Time
		if err := rows.Scan(&timestamp, &value); err != nil {
			return err
		}

		blocks.NewAtoms = append(blocks.NewAtoms, uint64(value))
	}
	// Set the genesis block to zero because the DB stores it as -1
	if len(blocks.NewAtoms) > 0 {
		blocks.NewAtoms[0] = 0
	}
	return nil
}
1109839
func Append(key string, value interface{}) {
	if !enabled || isDisabled(key) {
		return
	}
	bufferMu.Lock()
	if bufferItemCount >= maxBufferItems {
		bufferMu.Unlock()
		return
	}
	// TODO: Test this...
	bufVal, inBuffer := buffer[key]
	sliceVal, sliceOk := bufVal.([]interface{})
	if inBuffer && !sliceOk {
		bufferMu.Unlock()
		log.Printf("[PANIC] Telemetry: key %s already used for non-slice value", key)
		return
	}
	if sliceVal == nil {
		buffer[key] = []interface{}{value}
	} else if sliceOk {
		buffer[key] = append(sliceVal, value)
	}
	bufferItemCount++
	bufferMu.Unlock()
}
1187726
func (p *Provider) Append(systemRouter *mux.Router) {
	systemRouter.
		Methods(http.MethodPut).
		Path("/api/providers/{provider}").
		HandlerFunc(func(response http.ResponseWriter, request *http.Request) {

			vars := mux.Vars(request)
			if vars["provider"] != "rest" {
				response.WriteHeader(http.StatusBadRequest)
				fmt.Fprint(response, "Only 'rest' provider can be updated through the REST API")
				return
			}

			configuration := new(config.HTTPConfiguration)
			body, _ := ioutil.ReadAll(request.Body)

			if err := json.Unmarshal(body, configuration); err != nil {
				log.WithoutContext().Errorf("Error parsing configuration %+v", err)
				http.Error(response, fmt.Sprintf("%+v", err), http.StatusBadRequest)
				return
			}

			p.configurationChan <- config.Message{ProviderName: "rest", Configuration: &config.Configuration{
				HTTP: configuration,
			}}
			if err := templatesRenderer.JSON(response, http.StatusOK, configuration); err != nil {
				log.WithoutContext().Error(err)
			}
		})
}
1144160
func (s *Schema) Append(col *Column) {
	s.Columns = append(s.Columns, col)
}
85846
func (w *Writer) append(key, value []byte, restart bool) {
	nShared := 0
	if restart {
		w.restarts = append(w.restarts, uint32(len(w.buf)))
	} else {
		nShared = db.SharedPrefixLen(w.prevKey, key)
	}
	w.prevKey = append(w.prevKey[:0], key...)
	w.nEntries++
	n := binary.PutUvarint(w.tmp[0:], uint64(nShared))
	n += binary.PutUvarint(w.tmp[n:], uint64(len(key)-nShared))
	n += binary.PutUvarint(w.tmp[n:], uint64(len(value)))
	w.buf = append(w.buf, w.tmp[:n]...)
	w.buf = append(w.buf, key[nShared:]...)
	w.buf = append(w.buf, value...)
}
1048243
func (cAppender *consoleAppender) Append(event *Event) (ok bool) {
	ok = false
	defer gorivets.EndQuietly()
	msg := ToLogMessage(event, cAppender.layoutTemplate)
	if cAppender.async {
		caFactory.msgChannel <- msg
	} else {
		caFactory.write(msg)
	}
	ok = caFactory.msgChannel != nil
	return ok
}
130626
func (c *MockClient) Append(key string, value []byte) MutateResponse {
	return NewMutateErrorResponse(key, errors.Newf("Append not implemented"))
}
265694
func (h *Hashes) Append(hash *Hash) {
	h.hashes = append(h.hashes, hash.hash)
}
981498
func (c *CollectionBinary) Append(key string, val []byte, opts *AppendOptions) (mutOut *MutationResult, errOut error) {
	if opts == nil {
		opts = &AppendOptions{}
	}

	span := c.startKvOpTrace(opts.ParentSpanContext, "BinaryAppend")
	defer span.Finish()

	// Only update ctx if necessary, this means that the original ctx.Done() signal will be triggered as expected
	ctx, cancel := c.context(opts.Context, opts.Timeout)
	if cancel != nil {
		defer cancel()
	}

	res, err := c.append(ctx, span.Context(), key, val, *opts)
	if err != nil {
		return nil, err
	}

	return res, nil
}
1057361
func (d *Dataset) Append(row []interface{}) error {
	if len(row) != d.cols {
		return ErrInvalidDimensions
	}
	d.data = append(d.data, row)
	d.tags = append(d.tags, make([]string, 0))
	d.rows++
	return nil
}
1335392
func (t *TokenIntrospectionHandlers) Append(h TokenIntrospector) {
	for _, this := range *t {
		if reflect.TypeOf(this) == reflect.TypeOf(h) {
			return
		}
	}

	*t = append(*t, h)
}
959423
func (result *Result) AppendResult(src *Result) {
	if src.RowsAffected == 0 && len(src.Fields) == 0 {
		return
	}
	if result.Fields == nil {
		result.Fields = src.Fields
	}
	result.RowsAffected += src.RowsAffected
	if src.InsertID != 0 {
		result.InsertID = src.InsertID
	}
	if len(result.Rows) == 0 {
		// we haven't gotten any result yet, just save the new extras.
		result.Extras = src.Extras
	} else {
		// Merge the EventTokens / Fresher flags within Extras.
		if src.Extras == nil {
			// We didn't get any from innerq. Have to clear any
			// we'd have gotten already.
			if result.Extras != nil {
				result.Extras.EventToken = nil
				result.Extras.Fresher = false
			}
		} else {
			// We may have gotten an EventToken from
			// innerqr.  If we also got one earlier, merge
			// it. If we didn't get one earlier, we
			// discard the new one.
			if result.Extras != nil {
				// Note if any of the two is nil, we get nil.
				result.Extras.EventToken = EventTokenMinimum(result.Extras.EventToken, src.Extras.EventToken)

				result.Extras.Fresher = result.Extras.Fresher && src.Extras.Fresher
			}
		}
	}
	result.Rows = append(result.Rows, src.Rows...)
}
57522
func (db *DB) AppendBlockFeeRows(charts *cache.ChartData, rows *sql.Rows) error {
	defer rows.Close()
	blocks := charts.Blocks
	for rows.Next() {
		var feeMed float64
		var blockHeight uint64
		if err := rows.Scan(&blockHeight, &feeMed); err != nil {
			log.Errorf("Unable to scan for FeeInfoPerBlock fields: %v", err)
			return err
		}

		// Converting to atoms.
		blocks.Fees = append(blocks.Fees, uint64(feeMed*1e8))
	}

	return nil
}
712689
func appendChartBlocks(charts *cache.ChartData, rows *sql.Rows) error {
	defer closeRows(rows)

	// In order to store chainwork values as uint64, they are represented
	// as exahash (10^18) for work, and terahash/s (10^12) for hashrate.
	bigExa := big.NewInt(int64(1e18))
	badRows := 0
	// badRow is used to log chainwork errors without returning an error from
	// retrieveChartBlocks.
	badRow := func() {
		badRows++
	}

	var timeDef dbtypes.TimeDef
	var workhex string
	var count, size, height uint64
	var rowCount int32
	blocks := charts.Blocks
	for rows.Next() {
		rowCount++
		// Get the chainwork.
		err := rows.Scan(&height, &size, &timeDef, &workhex, &count)
		if err != nil {
			return err
		}

		bigwork, ok := new(big.Int).SetString(workhex, 16)
		if !ok {
			badRow()
			continue
		}
		bigwork.Div(bigwork, bigExa)
		if !bigwork.IsUint64() {
			badRow()
			// Something is wrong, but pretend that no work was done to keep the
			// datasets sized properly.
			bigwork = big.NewInt(int64(blocks.Chainwork[len(blocks.Chainwork)-1]))
		}
		blocks.Chainwork = append(blocks.Chainwork, bigwork.Uint64())
		blocks.TxCount = append(blocks.TxCount, count)
		blocks.Time = append(blocks.Time, uint64(timeDef.T.Unix()))
		blocks.BlockSize = append(blocks.BlockSize, size)
	}
	if badRows > 0 {
		log.Errorf("%d rows have invalid chainwork values.", badRows)
	}
	chainLen := len(blocks.Chainwork)
	if rowCount > 0 && uint64(chainLen-1) != height {
		return fmt.Errorf("retrieveChartBlocks: height misalignment. last height = %d. data length = %d", height, chainLen)
	}
	if len(blocks.Time) != chainLen || len(blocks.TxCount) != chainLen {
		return fmt.Errorf("retrieveChartBlocks: data length misalignment. len(chainwork) = %d, len(stamps) = %d, len(counts) = %d",
			chainLen, len(blocks.Time), len(blocks.TxCount))
	}

	return nil
}
401400
func (fl *FileLedger) Append(block *cb.Block) error {
	err := fl.blockStore.AddBlock(block)
	if err == nil {
		close(fl.signal)
		fl.signal = make(chan struct{})
	}
	return err
}
954746
func (s *Deque) Append(item interface{}) bool {
	s.Lock()
	defer s.Unlock()

	if s.capacity < 0 || s.container.Len() < s.capacity {
		s.container.PushBack(item)
		return true
	}

	return false
}
1219803
func (dt *DbfTable) Append(spec interface{}) int {
	return dt.Write(dt.AddRecord(), spec)
}