// BchEncode encodes the receiver to w using the bitcoin protocol encoding.
// This is part of the Message interface implementation.
BchEncode encodes the receiver to w using the bitcoin protocol encoding.
This is part of the Message interface implementation.
// BchEncode encodes the receiver to w using the bitcoin protocol encoding . // This is part of the Message interface implementation .
func (msg *MsgCmpctBlock) BchEncode(w io.Writer, pver uint32, enc MessageEncoding) error {
	if pver < BIP0152Version {
		str := fmt.Sprintf("cmpctblock message invalid for protocol "+
			"version %d", pver)
		return messageError("MsgCmpctBlock.BchDecode", str)
	}
	if err := writeBlockHeader(w, pver, &msg.Header); err != nil {
		return err
	}
	if err := writeElement(w, &msg.Nonce); err != nil {
		return err
	}
	if err := WriteVarInt(w, pver, uint64(len(msg.ShortIDs))); err != nil {
		return err
	}
	for _, shortID := range msg.ShortIDs {
		w.Write(shortID[:])
	}
	if err := WriteVarInt(w, pver, uint64(len(msg.PrefilledTxs))); err != nil {
		return err
	}
	for _, ptx := range msg.PrefilledTxs {
		if err := WriteVarInt(w, pver, uint64(ptx.Index)); err != nil {
			return err
		}
		if err := ptx.Tx.BchEncode(w, pver, enc); err != nil {
			return err
		}
	}
	return nil
}
func ( msg * MsgCmpctBlock ) BchEncode ( w io . Writer , pver uint32 , enc MessageEncoding ) error { if pver < BIP0152Version { str := fmt . Sprintf ( " " + " " , pver ) return messageError ( " " , str ) } if err := writeBlockHeader ( w , pver , & msg . Header ) ; err != nil { return err } if err := writeElement ( w , & msg . Nonce ) ; err != nil { return err } if err := WriteVarInt ( w , pver , uint64 ( len ( msg . ShortIDs ) ) ) ; err != nil { return err } for _ , shortID := range msg . ShortIDs { w . Write ( shortID [ : ] ) } if err := WriteVarInt ( w , pver , uint64 ( len ( msg . PrefilledTxs ) ) ) ; err != nil { return err } for _ , ptx := range msg . PrefilledTxs { if err := WriteVarInt ( w , pver , uint64 ( ptx . Index ) ) ; err != nil { return err } if err := ptx . Tx . BchEncode ( w , pver , enc ) ; err != nil { return err } } return nil }
BchEncode encodes the receiver to w using the bitcoin protocol encoding.
BchEncode encodes the receiver to w using the bitcoin protocol encoding .