Separate TransactionType to new file (#8)

This commit is contained in:
Charlie Revett 2018-02-01 10:05:56 -08:00 committed by GitHub
parent 5b9578db5d
commit a95ce31176
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 32 deletions

View file

@ -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
}

View file

@ -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 ""
}
}