-
Notifications
You must be signed in to change notification settings - Fork 95
/
feat_metadata_state.gen.go
91 lines (71 loc) · 2.1 KB
/
feat_metadata_state.gen.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package iotago
// Code generated by go generate; DO NOT EDIT. Check gen/ directory instead.
import (
"bytes"
"cmp"
"github.com/iotaledger/hive.go/lo"
"github.com/iotaledger/hive.go/serializer/v2"
)
type StateMetadataFeatureEntriesKey string
type StateMetadataFeatureEntriesValue []byte
type StateMetadataFeatureEntries map[StateMetadataFeatureEntriesKey]StateMetadataFeatureEntriesValue
// StateMetadataFeature is a feature which holds a map of key-value pairs.
// The keys must consist of ASCII characters only.
// The values are arbitrary byte slices.
type StateMetadataFeature struct {
Entries StateMetadataFeatureEntries `serix:""`
}
func (m StateMetadataFeature) Clone() Feature {
copiedMap := make(StateMetadataFeatureEntries)
for key, value := range m.Entries {
copiedMap[key] = lo.CopySlice(value)
}
return &StateMetadataFeature{
Entries: copiedMap,
}
}
func (m StateMetadataFeature) StorageScore(_ *StorageScoreStructure, _ StorageScoreFunc) StorageScore {
return 0
}
func (m StateMetadataFeature) WorkScore(_ *WorkScoreParameters) (WorkScore, error) {
return 0, nil
}
func (m StateMetadataFeature) Compare(other Feature) int {
return cmp.Compare(m.Type(), other.Type())
}
func (m StateMetadataFeature) Equal(other Feature) bool {
otherFeat, is := other.(*StateMetadataFeature)
if !is {
return false
}
if len(m.Entries) != len(otherFeat.Entries) {
return false
}
for key, value := range m.Entries {
otherValue, exists := otherFeat.Entries[key]
if !exists {
return false
}
if !bytes.Equal(value, otherValue) {
return false
}
}
return true
}
func (m StateMetadataFeature) Type() FeatureType {
return FeatureStateMetadata
}
func (m StateMetadataFeature) mapSize() int {
var size int
// Map Length
size += serializer.SmallTypeDenotationByteSize
for key, value := range m.Entries {
// Key Length + Key + Value Length + Value
size += serializer.SmallTypeDenotationByteSize + len(key) + serializer.UInt16ByteSize + len(value)
}
return size
}
func (m StateMetadataFeature) Size() int {
// FeatureType + Entries
return serializer.SmallTypeDenotationByteSize + m.mapSize()
}