From a95ce31176e47320cdbb4c97a7a039da31989f84 Mon Sep 17 00:00:00 2001 From: Charlie Revett Date: Thu, 1 Feb 2018 10:05:56 -0800 Subject: [PATCH] Separate TransactionType to new file (#8) --- pkg/core/transaction.go | 37 +++++------------------------------- pkg/core/transaction_type.go | 28 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 32 deletions(-) create mode 100644 pkg/core/transaction_type.go diff --git a/pkg/core/transaction.go b/pkg/core/transaction.go index da582461f..bc432bca1 100644 --- a/pkg/core/transaction.go +++ b/pkg/core/transaction.go @@ -5,31 +5,9 @@ import ( "io" ) -// TransactionType is the type of a transaction. -type TransactionType uint8 - -// String implements the stringer interface. -func (t TransactionType) String() string { - switch t { - case MinerTX: - return "miner transaction" - case IssueTX: - return "issue transaction" - case ClaimTX: - return "claim transaction" - case EnrollmentTX: - return "enrollment transaction" - case VotingTX: - return "voting transaction" - case RegisterTX: - return "register transaction" - case ContractTX: - return "contract transaction" - case AgencyTX: - return "agency transaction" - default: - return "" - } +// Transaction is a process recorded in the NEO system. +type Transaction struct { + Type TransactionType } // All processes in NEO system are recorded in transactions. @@ -45,18 +23,13 @@ const ( AgencyTX = 0xb0 ) -// Transaction is a process recorded in the NEO system. -type Transaction struct { - Type TransactionType -} - // DecodeBinary implements the payload interface. -func (t *Transaction) DecodeBinary(r io.Reader) error { +func (t Transaction) DecodeBinary(r io.Reader) error { err := binary.Read(r, binary.LittleEndian, &t.Type) return err } // EncodeBinary implements the payload interface. -func (t *Transaction) EncodeBinary(w io.Writer) error { +func (t Transaction) EncodeBinary(w io.Writer) error { return nil } diff --git a/pkg/core/transaction_type.go b/pkg/core/transaction_type.go new file mode 100644 index 000000000..3aafe0166 --- /dev/null +++ b/pkg/core/transaction_type.go @@ -0,0 +1,28 @@ +package core + +// TransactionType is the type of a transaction. +type TransactionType uint8 + +// String implements the stringer interface. +func (t TransactionType) String() string { + switch t { + case MinerTX: + return "miner transaction" + case IssueTX: + return "issue transaction" + case ClaimTX: + return "claim transaction" + case EnrollmentTX: + return "enrollment transaction" + case VotingTX: + return "voting transaction" + case RegisterTX: + return "register transaction" + case ContractTX: + return "contract transaction" + case AgencyTX: + return "agency transaction" + default: + return "" + } +}