Separate TransactionType to new file (#8)
This commit is contained in:
parent
5b9578db5d
commit
a95ce31176
2 changed files with 33 additions and 32 deletions
|
@ -5,31 +5,9 @@ import (
|
||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TransactionType is the type of a transaction.
|
// Transaction is a process recorded in the NEO system.
|
||||||
type TransactionType uint8
|
type Transaction struct {
|
||||||
|
Type TransactionType
|
||||||
// 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 ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// All processes in NEO system are recorded in transactions.
|
// All processes in NEO system are recorded in transactions.
|
||||||
|
@ -45,18 +23,13 @@ const (
|
||||||
AgencyTX = 0xb0
|
AgencyTX = 0xb0
|
||||||
)
|
)
|
||||||
|
|
||||||
// Transaction is a process recorded in the NEO system.
|
|
||||||
type Transaction struct {
|
|
||||||
Type TransactionType
|
|
||||||
}
|
|
||||||
|
|
||||||
// DecodeBinary implements the payload interface.
|
// 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)
|
err := binary.Read(r, binary.LittleEndian, &t.Type)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodeBinary implements the payload interface.
|
// EncodeBinary implements the payload interface.
|
||||||
func (t *Transaction) EncodeBinary(w io.Writer) error {
|
func (t Transaction) EncodeBinary(w io.Writer) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
28
pkg/core/transaction_type.go
Normal file
28
pkg/core/transaction_type.go
Normal 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 ""
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue