// BchDecode decodes r using the bitcoin protocol encoding into the receiver.
// This is part of the Message interface implementation.
BchDecode decodes r using the bitcoin protocol encoding into the receiver.
This is part of the Message interface implementation.
// BchDecode decodes r using the bitcoin protocol encoding into the receiver . // This is part of the Message interface implementation .
func (msg *MsgCmpctBlock) BchDecode(r io.Reader, 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 := readBlockHeader(r, pver, &msg.Header); err != nil {
		return err
	}
	if err := readElement(r, &msg.Nonce); err != nil {
		return err
	}
	shortIDCount, err := ReadVarInt(r, pver)
	if err != nil {
		return err
	}
	for i := uint64(0); i < shortIDCount; i++ {
		shortIDBytes := make([]byte, ShortIDSize)
		_, err = io.ReadFull(r, shortIDBytes)
		if err != nil {
			return err
		}
		var shortID [ShortIDSize]byte
		copy(shortID[:], shortIDBytes[:ShortIDSize])
		msg.ShortIDs = append(msg.ShortIDs, shortID)
	}
	prefilledTxCount, err := ReadVarInt(r, pver)
	if err != nil {
		return err
	}
	for i := uint64(0); i < prefilledTxCount; i++ {
		index, err := ReadVarInt(r, pver)
		if err != nil {
			return err
		}
		tx := MsgTx{}
		err = tx.BchDecode(r, pver, enc)
		if err != nil {
			return err
		}
		ptx := &PrefilledTx{
			Index: uint32(index),
			Tx:    &tx,
		}
		msg.PrefilledTxs = append(msg.PrefilledTxs, ptx)
	}
	return nil
}
func ( msg * MsgCmpctBlock ) BchDecode ( r io . Reader , pver uint32 , enc MessageEncoding ) error { if pver < BIP0152Version { str := fmt . Sprintf ( " " + " " , pver ) return messageError ( " " , str ) } if err := readBlockHeader ( r , pver , & msg . Header ) ; err != nil { return err } if err := readElement ( r , & msg . Nonce ) ; err != nil { return err } shortIDCount , err := ReadVarInt ( r , pver ) if err != nil { return err } for i := uint64 ( 0 ) ; i < shortIDCount ; i ++ { shortIDBytes := make ( [ ] byte , ShortIDSize ) _ , err = io . ReadFull ( r , shortIDBytes ) if err != nil { return err } var shortID [ ShortIDSize ] byte copy ( shortID [ : ] , shortIDBytes [ : ShortIDSize ] ) msg . ShortIDs = append ( msg . ShortIDs , shortID ) } prefilledTxCount , err := ReadVarInt ( r , pver ) if err != nil { return err } for i := uint64 ( 0 ) ; i < prefilledTxCount ; i ++ { index , err := ReadVarInt ( r , pver ) if err != nil { return err } tx := MsgTx { } err = tx . BchDecode ( r , pver , enc ) if err != nil { return err } ptx := & PrefilledTx { Index : uint32 ( index ) , Tx : & tx , } msg . PrefilledTxs = append ( msg . PrefilledTxs , ptx ) } return nil }
BchDecode decodes r using the bitcoin protocol encoding into the receiver.
BchDecode decodes r using the bitcoin protocol encoding into the receiver .