54d888ba70
This seriously improves the serialization/deserialization performance for several reasons: * no time spent in `binary` reflection * no memory allocations being made on every read/write * uses fast ReadBytes everywhere it's appropriate It also makes Fixed8 Serializable just for convenience.
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package transaction
|
|
|
|
import (
|
|
"github.com/CityOfZion/neo-go/pkg/crypto/keys"
|
|
"github.com/CityOfZion/neo-go/pkg/io"
|
|
"github.com/CityOfZion/neo-go/pkg/util"
|
|
)
|
|
|
|
// RegisterTX represents a register transaction.
|
|
// NOTE: This is deprecated.
|
|
type RegisterTX struct {
|
|
// The type of the asset being registered.
|
|
AssetType AssetType
|
|
|
|
// Name of the asset being registered.
|
|
Name string
|
|
|
|
// Amount registered.
|
|
// Unlimited mode -0.00000001.
|
|
Amount util.Fixed8
|
|
|
|
// Decimals.
|
|
Precision uint8
|
|
|
|
// Public key of the owner.
|
|
Owner keys.PublicKey
|
|
|
|
Admin util.Uint160
|
|
}
|
|
|
|
// DecodeBinary implements Serializable interface.
|
|
func (tx *RegisterTX) DecodeBinary(br *io.BinReader) {
|
|
tx.AssetType = AssetType(br.ReadByte())
|
|
|
|
tx.Name = br.ReadString()
|
|
|
|
tx.Amount.DecodeBinary(br)
|
|
tx.Precision = uint8(br.ReadByte())
|
|
|
|
tx.Owner.DecodeBinary(br)
|
|
|
|
br.ReadBytes(tx.Admin[:])
|
|
}
|
|
|
|
// EncodeBinary implements Serializable interface.
|
|
func (tx *RegisterTX) EncodeBinary(bw *io.BinWriter) {
|
|
bw.WriteByte(byte(tx.AssetType))
|
|
bw.WriteString(tx.Name)
|
|
tx.Amount.EncodeBinary(bw)
|
|
bw.WriteByte(byte(tx.Precision))
|
|
bw.WriteBytes(tx.Owner.Bytes())
|
|
bw.WriteBytes(tx.Admin[:])
|
|
}
|