// EncodeRLP implements rlp.Encoder.
495692
func (v Secp256k1) EncodeRLP(w io.Writer) error {
	return rlp.Encode(w, crypto.CompressPubkey((*ecdsa.PublicKey)(&v)))
}
8829
func (v IP) EncodeRLP(w io.Writer) error {
	if ip4 := net.IP(v).To4(); ip4 != nil {
		return rlp.Encode(w, ip4)
	}
	return rlp.Encode(w, net.IP(v))
}
568483
func (v Value) EncodeAscii(b encoding2.BinaryWriter) {
	if v.Inner == nil {
		if _, err := b.Write(nullstr); err != nil {
			panic(err)
		}
	} else {
		v.Inner.encodeAscii(b)
	}
}
596242
func (pp *Pingresp) Encode(dst []byte) (int, error) {
	return nakedEncode(dst, PINGRESP)
}
11316
func EncodeAll(src []uint64) ([]uint64, error) {
	i := 0

	// Re-use the input slice and write encoded values back in place
	dst := src
	j := 0

NEXTVALUE:
	for i < len(src) {
		remaining := src[i:]

		// try to pack run of 240 or 120 1s
		if len(remaining) >= 120 {
			// Invariant: len(a) is fixed to 120 or 240 values
			var a []uint64
			if len(remaining) >= 240 {
				a = remaining[:240]
			} else {
				a = remaining[:120]
			}

			// search for the longest sequence of 1s in a
			// Postcondition: k equals the index of the last 1 or -1
			k := 0
			for k = range a {
				if a[k] != 1 {
					k--
					break
				}
			}

			v := uint64(0)
			switch {
			case k == 239:
				// 240 1s
				i += 240

			case k >= 119:
				// at least 120 1s
				v = 1 << 60
				i += 120

			default:
				goto CODES
			}

			dst[j] = v
			j++
			continue
		}

	CODES:
		for code := range numBits {
			intN := int(numBits[code][0])
			bitN := numBits[code][1]
			if intN > len(remaining) {
				continue
			}

			maxVal := uint64(1 << (bitN & 0x3f))
			val := uint64(code+2) << S8B_BIT_SIZE

			for k, inV := range remaining {
				if k < intN {
					if inV >= maxVal {
						continue CODES
					}
					val |= inV << ((byte(k) * bitN) & 0x3f)
				} else {
					break
				}
			}
			dst[j] = val
			j += 1
			i += intN
			continue NEXTVALUE
		}
		return nil, ErrValueOutOfBounds
	}
	return dst[:j], nil
}
409831
func EncoderForType(encType string) Encoder {
	encLock.Lock()
	defer encLock.Unlock()
	return encMap[encType]
}
835428
func (dc *Context) EncodePNG(w io.Writer) error {
	return png.Encode(w, dc.im)
}
472529
func (p *Buffer) EncodeRawBytes(b []byte) error {
	p.EncodeVarint(uint64(len(b)))
	p.buf = append(p.buf, b...)
	return nil
}
571785
func (xw *Writer) encodeIndex(index *index) error {
	// Helper function to write VLIs.
	var crc uint32
	var errVLI error
	writeVLI := func(x int64) {
		b := xw.scratch[:binary.PutUvarint(xw.scratch[:], uint64(x))]
		crc = crc32.Update(crc, crc32.MakeTable(crc32.IEEE), b)
		if _, err := xw.mw.Write(b); err != nil {
			errVLI = errWrap(err)
		}
	}

	// Write the index.
	xw.mw.Reset(xw.wr)
	defer func() { xw.OutputOffset += xw.mw.OutputOffset }()
	xw.mw.FinalMode = meta.FinalMeta
	writeVLI(index.BackSize)
	writeVLI(int64(len(index.Records)))
	writeVLI(index.LastRecord().CompOffset)
	writeVLI(index.LastRecord().RawOffset)
	var preRec record
	for _, rec := range index.Records {
		writeVLI(rec.CompOffset - preRec.CompOffset)
		writeVLI(rec.RawOffset - preRec.RawOffset)
		preRec = rec
	}
	if errVLI != nil {
		return errWrap(errVLI)
	}

	binary.LittleEndian.PutUint32(xw.scratch[:], crc)
	if _, err := xw.mw.Write(xw.scratch[:4]); err != nil {
		return errWrap(err)
	}
	if err := xw.mw.Close(); err != nil {
		return errWrap(err)
	}
	index.IndexSize = xw.mw.OutputOffset // Record the encoded size
	return nil
}
939169
func (tx *Transaction) EncodeRLP(w io.Writer) error {
	return rlp.Encode(w, &tx.data)
}
949536
func (n *fullNode) EncodeRLP(w io.Writer) error {
	var nodes [17]node

	for i, child := range &n.Children {
		if child != nil {
			nodes[i] = child
		} else {
			nodes[i] = nilValueNode
		}
	}
	return rlp.Encode(w, nodes)
}
471230
func (b *Block) EncodeRLP(w io.Writer) error {
	return rlp.Encode(w, extblock{
		Header: b.header,
		Txs:    b.transactions,
		Uncles: b.uncles,
	})
}
1002128
func GetBodyRLP(ctx context.Context, odr OdrBackend, hash common.Hash, number uint64) (rlp.RawValue, error) {
	if data := rawdb.ReadBodyRLP(odr.Database(), hash, number); data != nil {
		return data, nil
	}
	r := &BlockRequest{Hash: hash, Number: number}
	if err := odr.Retrieve(ctx, r); err != nil {
		return nil, err
	} else {
		return r.Rlp, nil
	}
}
1157808
func (e *Encoder) Encode(v interface{}) error {
	val := reflect.ValueOf(v)
	return e.encode(val)
}
291211
func EncodeOptHTMLEscape(doEscape bool) EncodeOpt {
	return func(e *json.Encoder) {
		e.SetEscapeHTML(doEscape)
	}
}
529835
func (l *LogForStorage) EncodeRLP(w io.Writer) error {
	return rlp.Encode(w, rlpStorageLog{
		Address: l.Address,
		Topics:  l.Topics,
		Data:    l.Data,
	})
}
987195
func EncodeNode(node *Node) map[string]string {
	labels := make(map[string]string)
	encodeNode(labels, node.Name, node)
	return labels
}