// Encode serializes the retribution into the passed byte stream.
429336
func (ret *retributionInfo) Encode(w io.Writer) error {
	var scratch [4]byte

	if _, err := w.Write(ret.commitHash[:]); err != nil {
		return err
	}

	if err := writeOutpoint(w, &ret.chanPoint); err != nil {
		return err
	}

	if _, err := w.Write(ret.chainHash[:]); err != nil {
		return err
	}

	binary.BigEndian.PutUint32(scratch[:], ret.breachHeight)
	if _, err := w.Write(scratch[:]); err != nil {
		return err
	}

	nOutputs := len(ret.breachedOutputs)
	if err := wire.WriteVarInt(w, 0, uint64(nOutputs)); err != nil {
		return err
	}

	for _, output := range ret.breachedOutputs {
		if err := output.Encode(w); err != nil {
			return err
		}
	}

	return nil
}
712024
func (j JSONRequestBody) Encode() (requestBody io.Reader, contentType string, err error) {
	bodyJSON, err := json.Marshal(j.body)
	if err != nil {
		return nil, "", err
	}
	return bytes.NewReader(bodyJSON), "application/json", nil
}
69744
func Encode(charset int, utf_8 []byte) (latin []byte, success int, err error) {
	return converters[charset].Encode(utf_8)
}
621200
func (enc *Encoder) Encode(pb proto.Message) error {
	buf, err := proto.Marshal(pb)
	if err != nil {
		return err
	}

	if _, err := enc.w.Write(buf); err != nil {
		return err
	}

	return nil
}
877110
func (f *FailTemporaryChannelFailure) Encode(w io.Writer, pver uint32) error {
	var payload []byte
	if f.Update != nil {
		var bw bytes.Buffer
		if err := f.Update.Encode(&bw, pver); err != nil {
			return err
		}
		payload = bw.Bytes()
	}

	if err := WriteElement(w, uint16(len(payload))); err != nil {
		return err
	}

	_, err := w.Write(payload)
	return err
}
864944
func (codec *SyncCodec) Encode(data interface{}, out *ByteBuf) error {
	if msg, ok := data.(*notifyRaw); ok {
		out.WriteByte(cmdNotifyRaw)
		out.WriteByteBuf(msg.buf)
		releaseNotifyRaw(msg)
		return nil
	} else if msg, ok := data.(*notify); ok {
		out.WriteByte(cmdNotify)
		out.WriteUint64(msg.offset)
		releaseNotify(msg)
		return nil
	} else if msg, ok := data.(*notifySync); ok {
		out.WriteByte(cmdNotifySync)
		out.WriteUint64(msg.offset)
		releaseNotifySync(msg)
		return nil
	} else if msg, ok := data.(*notifySyncRsp); ok {
		out.WriteByte(cmdNotifySyncRsp)
		out.WriteUint64(msg.offset)
		out.WriteByte(msg.count)
		out.WriteByteBuf(msg.buf)
		releaseNotifySyncRsp(msg)
		return nil
	} else if msg, ok := data.(*notifyHB); ok {
		out.WriteByte(cmdNotifyHB)
		out.WriteUint64(msg.offset)
		return nil
	}

	return fmt.Errorf("not support msg: %v", data)
}
928499
func (enc *Encoder) Encode(m *Message) (err error) {

	_, err = enc.Write(m.Bytes())

	return
}
843740
func (f *CustomDownlinkFunctions) Encode(payload map[string]interface{}, port uint8) ([]byte, bool, error) {
	encoded, err := f.encode(payload, port)
	if err != nil {
		return nil, false, err
	}

	return encoded, true, nil
}
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
}
953726
func (this Slice) Encode() (BSON, error) {
	b, err := encodeSlice("", this)
	if err != nil {
		return nil, err
	}
	return b, nil
}
969453
func (e StringEncoder) Encode(data interface{}, out *goetty.ByteBuf) error {
	msg, _ := data.(string)
	bytes := []byte(msg)
	out.WriteInt(len(bytes))
	out.Write(bytes)
	return nil
}
529114
func (req *SnapshotRecoveryResponse) Encode(w io.Writer) (int, error) {
	pb := &protobuf.SnapshotRecoveryResponse{
		Term:        proto.Uint64(req.Term),
		Success:     proto.Bool(req.Success),
		CommitIndex: proto.Uint64(req.CommitIndex),
	}
	p, err := proto.Marshal(pb)
	if err != nil {
		return -1, err
	}

	return w.Write(p)
}
94831
func (up *Unsuback) Encode(dst []byte) (int, error) {
	return identifiedEncode(dst, up.ID, UNSUBACK)
}
1205387
func (w *Stream) Encode(m JSONMessage) error {
	return w.enc.Encode(m)
}
847616
func Encode(res *sawyer.Response, writer io.Writer) error {
	resCopy := CachedResponse{
		Expires:          expiration(res.Response),
		Status:           res.Status,
		StatusCode:       res.StatusCode,
		Proto:            res.Proto,
		ProtoMajor:       res.ProtoMajor,
		ProtoMinor:       res.ProtoMinor,
		Header:           res.Header,
		ContentLength:    res.ContentLength,
		TransferEncoding: res.TransferEncoding,
		Trailer:          res.Trailer,
	}

	if res.MediaType != nil {
		resCopy.MediaType = *res.MediaType
	}

	return EncodeResponse(&resCopy, writer)
}
881528
func Encode(v interface{}) ([]byte, error) {
	var buf bytes.Buffer
	zw := zlib.NewWriter(&buf)
	enc := json.NewEncoder(zw)

	if err := enc.Encode(v); err != nil {
		zw.Close()
		return nil, errors.Annotate(err, "failed to JSON-encode").Err()
	}
	if err := zw.Close(); err != nil {
		return nil, errors.Annotate(err, "failed to Close zlib Writer").Err()
	}
	return buf.Bytes(), nil
}
613153
func encode(buf *bytes.Buffer, b byte) {
	buf.WriteByte('=')
	buf.WriteByte(lowerhex[b>>4])
	buf.WriteByte(lowerhex[b&0x0f])
}