@@ -89,6 +89,18 @@ func (h *Hash) GetHex() string {
89
89
// Hashes represents a slice of hashes.
90
90
type Hashes struct { hashes []common.Hash }
91
91
92
+ // NewHashes creates a slice of uninitialized Hashes.
93
+ func NewHashes (size int ) * Hashes {
94
+ return & Hashes {
95
+ hashes : make ([]common.Hash , size ),
96
+ }
97
+ }
98
+
99
+ // NewHashesEmpty creates an empty slice of Hashes values.
100
+ func NewHashesEmpty () * Hashes {
101
+ return NewHashes (0 )
102
+ }
103
+
92
104
// Size returns the number of hashes in the slice.
93
105
func (h * Hashes ) Size () int {
94
106
return len (h .hashes )
@@ -102,6 +114,20 @@ func (h *Hashes) Get(index int) (hash *Hash, _ error) {
102
114
return & Hash {h .hashes [index ]}, nil
103
115
}
104
116
117
+ // Set sets the Hash at the given index in the slice.
118
+ func (h * Hashes ) Set (index int , hash * Hash ) error {
119
+ if index < 0 || index >= len (h .hashes ) {
120
+ return errors .New ("index out of bounds" )
121
+ }
122
+ h .hashes [index ] = hash .hash
123
+ return nil
124
+ }
125
+
126
+ // Append adds a new Hash element to the end of the slice.
127
+ func (h * Hashes ) Append (hash * Hash ) {
128
+ h .hashes = append (h .hashes , hash .hash )
129
+ }
130
+
105
131
// Address represents the 20 byte address of an Ethereum account.
106
132
type Address struct {
107
133
address common.Address
@@ -164,6 +190,18 @@ func (a *Address) GetHex() string {
164
190
// Addresses represents a slice of addresses.
165
191
type Addresses struct { addresses []common.Address }
166
192
193
+ // NewAddresses creates a slice of uninitialized addresses.
194
+ func NewAddresses (size int ) * Addresses {
195
+ return & Addresses {
196
+ addresses : make ([]common.Address , size ),
197
+ }
198
+ }
199
+
200
+ // NewAddressesEmpty creates an empty slice of Addresses values.
201
+ func NewAddressesEmpty () * Addresses {
202
+ return NewAddresses (0 )
203
+ }
204
+
167
205
// Size returns the number of addresses in the slice.
168
206
func (a * Addresses ) Size () int {
169
207
return len (a .addresses )
@@ -185,3 +223,8 @@ func (a *Addresses) Set(index int, address *Address) error {
185
223
a .addresses [index ] = address .address
186
224
return nil
187
225
}
226
+
227
+ // Append adds a new address element to the end of the slice.
228
+ func (a * Addresses ) Append (address * Address ) {
229
+ a .addresses = append (a .addresses , address .address )
230
+ }
0 commit comments