forked from denkhaus/go-bitshares
/
transaction.go
45 lines (35 loc) · 1.11 KB
/
transaction.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
package types
import (
"time"
"github.com/iuouiyiuty/bitshares/util"
"github.com/juju/errors"
)
type Transaction struct {
RefBlockNum UInt16 `json:"ref_block_num"`
RefBlockPrefix UInt32 `json:"ref_block_prefix"`
Expiration Time `json:"expiration"`
Operations Operations `json:"operations"`
Extensions Extensions `json:"extensions"`
}
func (p Transaction) Marshal(enc *util.TypeEncoder) error {
if err := enc.Encode(p.RefBlockNum); err != nil {
return errors.Annotate(err, "encode RefBlockNum")
}
if err := enc.Encode(p.RefBlockPrefix); err != nil {
return errors.Annotate(err, "encode RefBlockPrefix")
}
if err := enc.Encode(p.Expiration); err != nil {
return errors.Annotate(err, "encode Expiration")
}
if err := enc.Encode(p.Operations); err != nil {
return errors.Annotate(err, "encode Operations")
}
if err := enc.Encode(p.Extensions); err != nil {
return errors.Annotate(err, "encode Extension")
}
return nil
}
//AdjustExpiration extends expiration by given duration.
func (p *Transaction) AdjustExpiration(dur time.Duration) {
p.Expiration = p.Expiration.Add(dur)
}