mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-10-14 00:59:33 +00:00
[NOD-59] Rename txEncodingExcludeSubnetworkData (#215)
This commit is contained in:
parent
ee44eb20de
commit
a31c07e8f3
@ -106,7 +106,7 @@ type txEncoding uint8
|
|||||||
const (
|
const (
|
||||||
txEncodingFull txEncoding = 0
|
txEncodingFull txEncoding = 0
|
||||||
|
|
||||||
txEncodingExcludeSubNetworkData txEncoding = 1 << iota
|
txEncodingExcludePayload txEncoding = 1 << iota
|
||||||
|
|
||||||
txEncodingExcludeSignatureScript
|
txEncodingExcludeSignatureScript
|
||||||
)
|
)
|
||||||
@ -332,8 +332,8 @@ func (msg *MsgTx) TxHash() *daghash.Hash {
|
|||||||
// Ignore the error returns since the only way the encode could fail
|
// Ignore the error returns since the only way the encode could fail
|
||||||
// is being out of memory or due to nil pointers, both of which would
|
// is being out of memory or due to nil pointers, both of which would
|
||||||
// cause a run-time panic.
|
// cause a run-time panic.
|
||||||
buf := bytes.NewBuffer(make([]byte, 0, msg.serializeSize(txEncodingExcludeSubNetworkData)))
|
buf := bytes.NewBuffer(make([]byte, 0, msg.serializeSize(txEncodingExcludePayload)))
|
||||||
_ = msg.serialize(buf, txEncodingExcludeSubNetworkData)
|
_ = msg.serialize(buf, txEncodingExcludePayload)
|
||||||
|
|
||||||
hash := daghash.Hash(daghash.DoubleHashH(buf.Bytes()))
|
hash := daghash.Hash(daghash.DoubleHashH(buf.Bytes()))
|
||||||
return &hash
|
return &hash
|
||||||
@ -347,7 +347,7 @@ func (msg *MsgTx) TxID() daghash.TxID {
|
|||||||
// due to nil pointers, both of which would cause a run-time panic.
|
// due to nil pointers, both of which would cause a run-time panic.
|
||||||
var encodingFlags txEncoding
|
var encodingFlags txEncoding
|
||||||
if !msg.IsCoinBase() {
|
if !msg.IsCoinBase() {
|
||||||
encodingFlags = txEncodingExcludeSignatureScript | txEncodingExcludeSubNetworkData
|
encodingFlags = txEncodingExcludeSignatureScript | txEncodingExcludePayload
|
||||||
}
|
}
|
||||||
buf := bytes.NewBuffer(make([]byte, 0, msg.serializeSize(encodingFlags)))
|
buf := bytes.NewBuffer(make([]byte, 0, msg.serializeSize(encodingFlags)))
|
||||||
_ = msg.serialize(buf, encodingFlags)
|
_ = msg.serialize(buf, encodingFlags)
|
||||||
@ -699,7 +699,7 @@ func (msg *MsgTx) encode(w io.Writer, pver uint32, encodingFlags txEncoding) err
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if encodingFlags&txEncodingExcludeSubNetworkData != txEncodingExcludeSubNetworkData {
|
if encodingFlags&txEncodingExcludePayload != txEncodingExcludePayload {
|
||||||
err = WriteVarInt(w, pver, uint64(len(msg.Payload)))
|
err = WriteVarInt(w, pver, uint64(len(msg.Payload)))
|
||||||
w.Write(msg.Payload)
|
w.Write(msg.Payload)
|
||||||
} else {
|
} else {
|
||||||
@ -769,7 +769,7 @@ func (msg *MsgTx) serializeSize(encodingFlags txEncoding) int {
|
|||||||
n += daghash.HashSize
|
n += daghash.HashSize
|
||||||
|
|
||||||
// Serialized varint size for the length of the payload
|
// Serialized varint size for the length of the payload
|
||||||
if encodingFlags&txEncodingExcludeSubNetworkData != txEncodingExcludeSubNetworkData {
|
if encodingFlags&txEncodingExcludePayload != txEncodingExcludePayload {
|
||||||
n += VarIntSerializeSize(uint64(len(msg.Payload)))
|
n += VarIntSerializeSize(uint64(len(msg.Payload)))
|
||||||
n += len(msg.Payload)
|
n += len(msg.Payload)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user