mirror of
https://github.com/kaspanet/kaspad.git
synced 2026-03-14 04:14:56 +00:00
BIP0144+wire: add a MessageEncoding variant for serialization/deserialization
This commit modifies the existing wire.Message interface to introduce a new MessageEncoding variant which dictates the exact encoding to be used when serializing and deserializing messages. Such an option is now necessary due to the segwit soft-fork package, as btcd will need to be able to optionally encode transactions/blocks without witness data to un-upgraded peers. Two new functions have been introduced: ReadMessageWithEncodingN and WriteMessageWithEncodingN which wrap BtcDecode/BtcEncode with the desired encoding format.
This commit is contained in:
committed by
Dave Collins
parent
1b359e1131
commit
48abfdf87c
@@ -60,7 +60,7 @@ func (h *BlockHeader) BlockHash() chainhash.Hash {
|
||||
// This is part of the Message interface implementation.
|
||||
// See Deserialize for decoding block headers stored to disk, such as in a
|
||||
// database, as opposed to decoding block headers from the wire.
|
||||
func (h *BlockHeader) BtcDecode(r io.Reader, pver uint32) error {
|
||||
func (h *BlockHeader) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error {
|
||||
return readBlockHeader(r, pver, h)
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (h *BlockHeader) BtcDecode(r io.Reader, pver uint32) error {
|
||||
// This is part of the Message interface implementation.
|
||||
// See Serialize for encoding block headers to be stored to disk, such as in a
|
||||
// database, as opposed to encoding block headers for the wire.
|
||||
func (h *BlockHeader) BtcEncode(w io.Writer, pver uint32) error {
|
||||
func (h *BlockHeader) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error {
|
||||
return writeBlockHeader(w, pver, h)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user