2018-03-04 13:56:49 +00:00
|
|
|
package transaction
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/binary"
|
|
|
|
"io"
|
|
|
|
)
|
|
|
|
|
|
|
|
// MinerTX represents a miner transaction.
|
|
|
|
type MinerTX struct {
|
2018-03-25 10:45:54 +00:00
|
|
|
// Random number to avoid hash collision.
|
2018-03-04 13:56:49 +00:00
|
|
|
Nonce uint32
|
|
|
|
}
|
|
|
|
|
|
|
|
// DecodeBinary implements the Payload interface.
|
|
|
|
func (tx *MinerTX) DecodeBinary(r io.Reader) error {
|
|
|
|
return binary.Read(r, binary.LittleEndian, &tx.Nonce)
|
|
|
|
}
|
|
|
|
|
|
|
|
// EncodeBinary implements the Payload interface.
|
|
|
|
func (tx *MinerTX) EncodeBinary(w io.Writer) error {
|
|
|
|
return binary.Write(w, binary.LittleEndian, tx.Nonce)
|
|
|
|
}
|
2019-08-30 08:28:30 +00:00
|
|
|
|
2019-09-03 14:51:37 +00:00
|
|
|
// Size returns serialized binary size for this transaction.
|
2019-08-30 08:28:30 +00:00
|
|
|
func (tx *MinerTX) Size() int {
|
|
|
|
return 4 // Nonce
|
|
|
|
}
|