pkg: hide it by moving to _pkg.dev
The idea here is to preserve the history of `dev` branch development and its code when merging with the `master`. Later this code could be moved into the masters code where appropriate.
This commit is contained in:
parent
bb2568cc53
commit
ddd1d92ff1
183 changed files with 0 additions and 0 deletions
55
_pkg.dev/wire/payload/transaction/statedescriptor.go
Normal file
55
_pkg.dev/wire/payload/transaction/statedescriptor.go
Normal file
|
@ -0,0 +1,55 @@
|
|||
package transaction
|
||||
|
||||
import (
|
||||
"github.com/CityOfZion/neo-go/pkg/wire/util"
|
||||
)
|
||||
|
||||
// DescStateType represents the type of StateDescriptor.
|
||||
type DescStateType uint8
|
||||
|
||||
// Valid DescStateType constants.
|
||||
const (
|
||||
Account DescStateType = 0x40
|
||||
Validator DescStateType = 0x48
|
||||
)
|
||||
|
||||
// StateDescriptor represents a state descriptor on the neo network
|
||||
// used in a state transaction
|
||||
type StateDescriptor struct {
|
||||
Type DescStateType
|
||||
Key []byte
|
||||
Value []byte
|
||||
Field string
|
||||
}
|
||||
|
||||
// Decode decodes a binary reader into a state descriptor
|
||||
func (s *StateDescriptor) Decode(br *util.BinReader) {
|
||||
br.Read(&s.Type)
|
||||
|
||||
keyLen := br.VarUint()
|
||||
s.Key = make([]byte, keyLen)
|
||||
br.Read(s.Key)
|
||||
|
||||
valLen := br.VarUint()
|
||||
s.Value = make([]byte, valLen)
|
||||
br.Read(s.Value)
|
||||
|
||||
fieldLen := br.VarUint()
|
||||
field := make([]byte, fieldLen)
|
||||
br.Read(field)
|
||||
|
||||
s.Field = string(field)
|
||||
}
|
||||
|
||||
//Encode encodes a state descriptor into a binary writer
|
||||
func (s *StateDescriptor) Encode(bw *util.BinWriter) {
|
||||
bw.Write(s.Type)
|
||||
|
||||
bw.VarUint(uint64(len(s.Key)))
|
||||
bw.Write(s.Key)
|
||||
|
||||
bw.VarUint(uint64(len(s.Value)))
|
||||
bw.Write(s.Value)
|
||||
|
||||
bw.VarString(s.Field)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue