mirror of
https://github.com/kaspanet/kaspad.git
synced 2026-03-02 15:13:13 +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
@@ -27,7 +27,7 @@ type MsgPing struct {
|
||||
|
||||
// BtcDecode decodes r using the bitcoin protocol encoding into the receiver.
|
||||
// This is part of the Message interface implementation.
|
||||
func (msg *MsgPing) BtcDecode(r io.Reader, pver uint32) error {
|
||||
func (msg *MsgPing) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error {
|
||||
// There was no nonce for BIP0031Version and earlier.
|
||||
// NOTE: > is not a mistake here. The BIP0031 was defined as AFTER
|
||||
// the version unlike most others.
|
||||
@@ -43,7 +43,7 @@ func (msg *MsgPing) BtcDecode(r io.Reader, pver uint32) error {
|
||||
|
||||
// BtcEncode encodes the receiver to w using the bitcoin protocol encoding.
|
||||
// This is part of the Message interface implementation.
|
||||
func (msg *MsgPing) BtcEncode(w io.Writer, pver uint32) error {
|
||||
func (msg *MsgPing) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error {
|
||||
// There was no nonce for BIP0031Version and earlier.
|
||||
// NOTE: > is not a mistake here. The BIP0031 was defined as AFTER
|
||||
// the version unlike most others.
|
||||
|
||||
Reference in New Issue
Block a user