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

Method WithOwnerState

x/cert/keeper/keeper.go:214–236  ·  view source on GitHub ↗

WithOwnerState iterates all certificates by owner in certain state

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

Source from the content-addressed store, hash-verified

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) {
215 store := ctx.KVStore(k.skey)
216
217 searchPrefix, err := filterToPrefix(types.CertificateFilter{
218 Owner: id.String(),
219 State: state.String(),
220 })
221 if err != nil {
222 panic(err)
223 }
224
225 iter := storetypes.KVStorePrefixIterator(store, searchPrefix)
226 defer func() {
227 _ = iter.Close()
228 }()
229
230 for ; iter.Valid(); iter.Next() {
231 _, item := k.mustUnmarshal(iter.Key(), iter.Value())
232 if stop := fn(item); stop {
233 break
234 }
235 }
236}
237
238func (k keeper) unmarshal(key, val []byte) (types.CertID, types.CertificateResponse, error) {
239 _, id, err := ParseCertKey(key)

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