/
address.go
61 lines (47 loc) · 1.02 KB
/
address.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
package hornet
import (
"github.com/iotaledger/hive.go/objectstorage"
)
const (
AddressTxIsValue = 1
)
type Address struct {
objectstorage.StorableObjectFlags
address Hash
isValue bool
txHash Hash
}
func NewAddress(address Hash, txHash Hash, isValue bool) *Address {
return &Address{
address: address,
isValue: isValue,
txHash: txHash,
}
}
func (a *Address) GetAddress() Hash {
return a.address
}
func (a *Address) GetTxHash() Hash {
return a.txHash
}
func (a *Address) IsValue() bool {
return a.isValue
}
// ObjectStorage interface
func (a *Address) Update(_ objectstorage.StorableObject) {
panic("Address should never be updated")
}
func (a *Address) ObjectStorageKey() []byte {
var isValueByte byte
if a.isValue {
isValueByte = AddressTxIsValue
}
result := append(a.address, isValueByte)
return append(result, a.txHash...)
}
func (a *Address) ObjectStorageValue() (_ []byte) {
return nil
}
func (a *Address) UnmarshalObjectStorageValue(_ []byte) (consumedBytes int, err error) {
return 0, nil
}