/
transfer_documents_item.go
75 lines (61 loc) · 1.72 KB
/
transfer_documents_item.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
71
72
73
74
75
package blocksign
import (
"github.com/spikeekips/mitum-currency/currency"
"github.com/spikeekips/mitum/base"
"github.com/spikeekips/mitum/util"
"github.com/spikeekips/mitum/util/hint"
)
type BaseTransferDocumentsItem struct {
hint hint.Hint
docId currency.Big // document id
owner base.Address // document owner
receiver base.Address // document receiver
cid currency.CurrencyID
}
func NewBaseTransferDocumentsItem(ht hint.Hint, docId currency.Big, owner base.Address, receiver base.Address, cid currency.CurrencyID) BaseTransferDocumentsItem {
return BaseTransferDocumentsItem{
hint: ht,
docId: docId,
owner: owner,
receiver: receiver,
cid: cid,
}
}
func (it BaseTransferDocumentsItem) Hint() hint.Hint {
return it.hint
}
func (it BaseTransferDocumentsItem) Bytes() []byte {
bs := make([][]byte, 4)
bs[0] = it.docId.Bytes()
bs[1] = it.owner.Bytes()
bs[2] = it.receiver.Bytes()
bs[3] = it.cid.Bytes()
return util.ConcatBytesSlice(bs...)
}
func (it BaseTransferDocumentsItem) IsValid([]byte) error {
if err := it.docId.IsValid(nil); err != nil {
return err
} else if err := it.owner.IsValid(nil); err != nil {
return err
} else if err := it.receiver.IsValid(nil); err != nil {
return err
} else if err := it.cid.IsValid(nil); err != nil {
return err
}
return nil
}
func (it BaseTransferDocumentsItem) DocumentId() currency.Big {
return it.docId
}
func (it BaseTransferDocumentsItem) Owner() base.Address {
return it.owner
}
func (it BaseTransferDocumentsItem) Receiver() base.Address {
return it.receiver
}
func (it BaseTransferDocumentsItem) Currency() currency.CurrencyID {
return it.cid
}
func (it BaseTransferDocumentsItem) Rebuild() TransferDocumentsItem {
return it
}