-
Notifications
You must be signed in to change notification settings - Fork 0
/
witnessupdateoperation.go
70 lines (55 loc) · 1.76 KB
/
witnessupdateoperation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package operations
//go:generate ffjson $GOFILE
import (
"github.com/CybexDex/cybex-go/types"
"github.com/CybexDex/cybex-go/util"
"github.com/juju/errors"
)
func init() {
types.OperationMap[types.OperationTypeWitnessUpdate] = func() types.Operation {
op := &WitnessUpdateOperation{}
return op
}
}
type WitnessUpdateOperation struct {
types.OperationFee
NewSigningKey *types.PublicKey `json:"new_signing_key"`
NewURL string `json:"new_url"`
Witness types.GrapheneID `json:"witness"`
WitnessAccount types.GrapheneID `json:"witness_account"`
}
func (p WitnessUpdateOperation) Type() types.OperationType {
return types.OperationTypeWitnessUpdate
}
func (p WitnessUpdateOperation) Marshal(enc *util.TypeEncoder) error {
if err := enc.Encode(int8(p.Type())); err != nil {
return errors.Annotate(err, "encode OperationType")
}
if err := enc.Encode(p.Fee); err != nil {
return errors.Annotate(err, "encode fee")
}
if err := enc.Encode(p.Witness); err != nil {
return errors.Annotate(err, "encode new options")
}
if err := enc.Encode(p.WitnessAccount); err != nil {
return errors.Annotate(err, "encode WitnessAccount")
}
if err := enc.Encode(p.NewURL != ""); err != nil {
return errors.Annotate(err, "encode have NewURL")
}
if err := enc.Encode(p.NewURL); err != nil {
return errors.Annotate(err, "encode NewURL")
}
if err := enc.Encode(p.NewSigningKey != nil); err != nil {
return errors.Annotate(err, "encode have NewSigningKey")
}
if err := enc.Encode(p.NewSigningKey); err != nil {
return errors.Annotate(err, "encode NewSigningKey")
}
return nil
}
//NewWitnessUpdateOperation creates a new WitnessUpdateOperation
func NewWitnessUpdateOperation() *WitnessUpdateOperation {
tx := WitnessUpdateOperation{}
return &tx
}