neoneo-go/pkg/core/transaction/miner.go
Roman Khimov 683424cce8 transaction: implement proper Size() everywhere
Will be needed for the block test from `dev`.
2019-08-30 11:41:10 +03:00

26 lines
558 B
Go

package transaction
import (
"encoding/binary"
"io"
)
// MinerTX represents a miner transaction.
type MinerTX struct {
// Random number to avoid hash collision.
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)
}
func (tx *MinerTX) Size() int {
return 4 // Nonce
}