// EncodeRLP implements rlp.Encoder.
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))
}
416096
func (r *Receipt) EncodeRLP(w io.Writer) error {
	return rlp.Encode(w, &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs})
}
355960
func EncoderDecoderFromString(str string) encoders.EncoderDecoder {
	var res encoders.EncoderDecoder
	switch str {
	case "gzip":
		res = &gzip.Gzip{}
	case "aes":
		res = &aes.AES{}
	case "openpgp":
		res = &openpgp.OpenPGP{}
	}
	return res
}
640869
func (v *RPC) GetEncoding() (o string) {
	if v != nil {
		o = v.Encoding
	}
	return
}
673885
func (l *Log) DecodeRLP(s *rlp.Stream) error {
	var dec rlpLog
	err := s.Decode(&dec)
	if err == nil {
		l.Address, l.Topics, l.Data = dec.Address, dec.Topics, dec.Data
	}
	return err
}
274451
func EncodeURLParamMap(m *URLParamMap) string {

	parameters := url.Values{}

	for k, v := range *m {
		l := len(v)
		for x := 0; x < l; x++ {
			parameters.Add(k, v[x])
		}

	}

	qEncoded := parameters.Encode()
	return string(qEncoded)

}
880749
func (q *QRCode) encode(numTerminatorBits int) {
	q.addTerminatorBits(numTerminatorBits)
	q.addPadding()

	encoded := q.encodeBlocks()

	const numMasks int = 8
	penalty := 0

	for mask := 0; mask < numMasks; mask++ {
		var s *symbol
		var err error

		s, err = buildRegularSymbol(q.version, mask, encoded)

		if err != nil {
			log.Panic(err.Error())
		}

		numEmptyModules := s.numEmptyModules()
		if numEmptyModules != 0 {
			log.Panicf("bug: numEmptyModules is %d (expected 0) (version=%d)",
				numEmptyModules, q.VersionNumber)
		}

		p := s.penaltyScore()

		//log.Printf("mask=%d p=%3d p1=%3d p2=%3d p3=%3d p4=%d\n", mask, p, s.penalty1(), s.penalty2(), s.penalty3(), s.penalty4())

		if q.symbol == nil || p < penalty {
			q.symbol = s
			q.mask = mask
			penalty = p
		}
	}
}
792147
func encodeHTTP(v url.Values, p map[string]string) {
	for k, pv := range p {
		v.Set("openid."+k, pv)
	}
}
691177
func (c *Error) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		c.ChanID,
		c.Data,
	)
}
596242
func (pp *Pingresp) Encode(dst []byte) (int, error) {
	return nakedEncode(dst, PINGRESP)
}
82569
func EncodeString(data string) string {
	return strings.Join([]string{strconv.Itoa(len(data)), data}, ":")
}
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
}
961322
func EncoderFromJSON(js json.RawMessage) (encoders.Encoder, error) {
	tmp := struct {
		Type string `json:"encoder"`
	}{}
	if err := json.Unmarshal(js, &tmp); err != nil {
		return nil, err
	} else if res := EncoderDecoderFromString(tmp.Type); res == nil {
		return nil, fmt.Errorf("encoder of type '%s' is not supported", tmp.Type)
	} else {
		return res, UnmarshalAndStart(res, js)
	}
}
545299
func (enc *HTTPEncoder) EncodeJSONP(callback string, model Model) error {
	setContentType(enc.writer, ContentJSONP)

	data, _ := json.Marshal(model)
	_, err := fmt.Fprintf(enc.writer, "%s(%s)", callback, string(data))
	if err != nil {
		http.Error(enc.writer, fmt.Sprintf("Unable to encode '%v' as JSON for javascript func %s: %s", model, callback, err.Error()), http.StatusInternalServerError)
	}
	return err
}
1036617
func (e *Encoder) Encode(v interface{}) (err error) {
	defer func() {
		if r := recover(); r != nil {
			if _, ok := r.(runtime.Error); ok {
				panic(r)
			}
			if s, ok := r.(string); ok {
				panic(s)
			}
			err = r.(error)
		}
	}()
	e.b.Clear()
	reflectValue(&e.b, reflect.ValueOf(v), encoderOptions{})
	if _, err := e.b.WriteTo(e.w); err != nil {
		return WithStack(err)
	}
	return nil
}
832122
func (b ENRAddrEntry) EncodeRLP(w io.Writer) error {
	log.Debug("in encoderlp", "b", b, "p", fmt.Sprintf("%p", &b))
	return rlp.Encode(w, &b.data)
}
969943
func WriteBodyRLP(db ethdb.Writer, hash common.Hash, number uint64, rlp rlp.RawValue) {
	if err := db.Put(blockBodyKey(number, hash), rlp); err != nil {
		log.Crit("Failed to store block body", "err", err)
	}
}