MCPcopy Create free account
hub / github.com/akash-network/node / WithOwner

Method WithOwner

x/cert/keeper/keeper.go:177–211  ·  view source on GitHub ↗

WithOwner iterates all certificates by owner

(ctx sdk.Context, id sdk.Address, fn func(types.CertificateResponse) bool)

Source from the content-addressed store, hash-verified

175
176// WithOwner iterates all certificates by owner
177func (k keeper) WithOwner(ctx sdk.Context, id sdk.Address, fn func(types.CertificateResponse) bool) {
178 store := ctx.KVStore(k.skey)
179
180 states := []types.State{
181 types.CertificateValid,
182 types.CertificateRevoked,
183 }
184
185 iters := make([]storetypes.Iterator, 0, len(states))
186 defer func() {
187 for _, iter := range iters {
188 _ = iter.Close()
189 }
190 }()
191
192 for _, state := range states {
193 searchPrefix, err := filterToPrefix(types.CertificateFilter{
194 Owner: id.String(),
195 State: state.String(),
196 })
197 if err != nil {
198 panic(err)
199 }
200
201 iter := storetypes.KVStorePrefixIterator(store, searchPrefix)
202 iters = append(iters, iter)
203
204 for ; iter.Valid(); iter.Next() {
205 _, item := k.mustUnmarshal(iter.Key(), iter.Value())
206 if stop := fn(item); stop {
207 break
208 }
209 }
210 }
211}
212
213// WithOwnerState iterates all certificates by owner in certain state
214func (k keeper) WithOwnerState(ctx sdk.Context, id sdk.Address, state types.State, fn func(types.CertificateResponse) bool) {

Callers

nothing calls this directly

Calls 5

mustUnmarshalMethod · 0.95
filterToPrefixFunction · 0.70
CloseMethod · 0.65
ValueMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected