cosmos-sdk/core/store/store.go
Aaron Craelius a53a593da1
feat: make 0.53 compatible with core-less collections v1.2.x (#24088)
Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com>
Co-authored-by: Alex | Interchain Labs <alex@interchainlabs.io>
2025-04-01 15:57:11 +00:00

37 lines
1.4 KiB
Go

package store
import dbm "github.com/cosmos/cosmos-db"
// KVStore describes the basic interface for interacting with key-value stores.
type KVStore = interface {
// Get returns nil iff key doesn't exist. Errors on nil key.
Get(key []byte) ([]byte, error)
// Has checks if a key exists. Errors on nil key.
Has(key []byte) (bool, error)
// Set sets the key. Errors on nil key or value.
Set(key, value []byte) error
// Delete deletes the key. Errors on nil key.
Delete(key []byte) error
// Iterator iterates over a domain of keys in ascending order. End is exclusive.
// Start must be less than end, or the Iterator is invalid.
// Iterator must be closed by caller.
// To iterate over entire domain, use store.Iterator(nil, nil)
// CONTRACT: No writes may happen within a domain while an iterator exists over it.
// Exceptionally allowed for cachekv.Store, safe to write in the modules.
Iterator(start, end []byte) (Iterator, error)
// ReverseIterator iterates over a domain of keys in descending order. End is exclusive.
// Start must be less than end, or the Iterator is invalid.
// Iterator must be closed by caller.
// CONTRACT: No writes may happen within a domain while an iterator exists over it.
// Exceptionally allowed for cachekv.Store, safe to write in the modules.
ReverseIterator(start, end []byte) (Iterator, error)
}
// Iterator is an alias db's Iterator for convenience.
type Iterator = dbm.Iterator