keeper

package
v0.0.0-...-1d67c2a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Media types.
	JSONLines = "JSON Lines"

	// CapData transformation formats.
	FormatCapDataFlat = "flat"

	// CapData remotable value formats.
	FormatRemotableAsObject = "object"
	FormatRemotableAsString = "string"
)
View Source
const (
	QueryData     = "data"
	QueryChildren = "children"
)

query endpoints supported by the vstorage Querier

View Source
const MetricLabelStoreKey = "storeKey"

Variables

View Source
var MaxSDKInt = sdkmath.NewIntFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(256), nil), big.NewInt(1)))

2 ** 256 - 1

View Source
var MetricKeyStoreSizeDecrease = []string{"store", "size_decrease"}
View Source
var MetricKeyStoreSizeIncrease = []string{"store", "size_increase"}

size_increase and size_decπrease metrics represent total writes and deletes *issued* respectively, which may differ from the total number of bytes committed/freed to/from the store due to the store's internal implementation.

Functions

This section is empty.

Types

type BatchingChangeManager

type BatchingChangeManager struct {
	// contains filtered or unexported fields
}

func NewBatchingChangeManager

func NewBatchingChangeManager() *BatchingChangeManager

The BatchingChangeManager needs to be a pointer because its state is mutated.

func (*BatchingChangeManager) EmitEvents

func (bcm *BatchingChangeManager) EmitEvents(ctx sdk.Context, k Keeper) error

EmitEvents emits events for all actual changes. This does not clear the cache, so the caller must call Rollback() to do so.

func (*BatchingChangeManager) Rollback

func (bcm *BatchingChangeManager) Rollback(ctx sdk.Context) error

func (*BatchingChangeManager) Track

func (bcm *BatchingChangeManager) Track(ctx sdk.Context, k Keeper, entry agoric.KVEntry, isLegacy bool) error

type ChangeManager

type ChangeManager interface {
	Track(ctx sdk.Context, k Keeper, entry agoric.KVEntry, isLegacy bool) error
	EmitEvents(ctx sdk.Context, k Keeper) error
	Rollback(ctx sdk.Context) error
}

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

Keeper maintains the link to data storage and exposes getter/setter methods for the various parts of the state machine

func NewKeeper

func NewKeeper(storeName string, storeService corestore.KVStoreService) Keeper

func (Keeper) AppendStorageValueAndNotify

func (k Keeper) AppendStorageValueAndNotify(ctx sdk.Context, path, value string) error

func (Keeper) EmitChange

func (k Keeper) EmitChange(ctx sdk.Context, change *ProposedChange)

func (Keeper) ExportStorage

func (k Keeper) ExportStorage(ctx sdk.Context) ([]*types.DataEntry, error)

ExportStorage fetches all storage

func (Keeper) ExportStorageFromPrefix

func (k Keeper) ExportStorageFromPrefix(ctx sdk.Context, pathPrefix string) ([]*types.DataEntry, error)

ExportStorageFromPrefix fetches storage only under the supplied pathPrefix.

func (Keeper) FlushChangeEvents

func (k Keeper) FlushChangeEvents(ctx sdk.Context) error

func (Keeper) GetChildren

func (k Keeper) GetChildren(ctx sdk.Context, path string) []string

GetChildren gets all vstorage child children at a given path

func (Keeper) GetDataPrefix

func (k Keeper) GetDataPrefix() []byte

func (Keeper) GetEntry

func (k Keeper) GetEntry(ctx sdk.Context, path string) agoric.KVEntry

GetEntry gets generic storage. The default value is an empty string.

func (Keeper) GetIntValue

func (k Keeper) GetIntValue(ctx sdk.Context, path string) (sdkmath.Int, error)

func (Keeper) GetNoDataValue

func (k Keeper) GetNoDataValue() []byte

func (Keeper) GetQueueLength

func (k Keeper) GetQueueLength(ctx sdk.Context, queuePath string) (sdkmath.Int, error)

func (Keeper) GetStoreName

func (k Keeper) GetStoreName() string

func (Keeper) HasChildren

func (k Keeper) HasChildren(ctx sdk.Context, path string) bool

HasChildren tells if a given path has child nodes.

func (Keeper) HasEntry

func (k Keeper) HasEntry(ctx sdk.Context, path string) bool

HasEntry tells if a given path has either subnodes or data.

func (Keeper) HasStorage

func (k Keeper) HasStorage(ctx sdk.Context, path string) bool

HasStorage tells if a given path has data. Some storage nodes have no data (just an empty string) and exist only to provide linkage to subnodes with data.

func (Keeper) ImportStorage

func (k Keeper) ImportStorage(ctx sdk.Context, entries []*types.DataEntry) error

func (Keeper) LegacySetStorageAndNotify

func (k Keeper) LegacySetStorageAndNotify(ctx sdk.Context, entry agoric.KVEntry)

func (Keeper) NewChangeBatch

func (k Keeper) NewChangeBatch(ctx sdk.Context) error

func (Keeper) PathToEncodedKey

func (k Keeper) PathToEncodedKey(path string) []byte

func (Keeper) PushQueueItem

func (k Keeper) PushQueueItem(ctx sdk.Context, queuePath string, value string) error

func (Keeper) RemoveEntriesWithPrefix

func (k Keeper) RemoveEntriesWithPrefix(ctx sdk.Context, pathPrefix string)

RemoveEntriesWithPrefix removes all storage entries starting with the supplied pathPrefix, which may not be empty. It has the same effect as listing children of the prefix and removing each descendant recursively.

func (Keeper) SetStorage

func (k Keeper) SetStorage(ctx sdk.Context, entry agoric.KVEntry)

SetStorage sets the data value for a path.

Maintains the invariant: path entries exist if and only if self or some descendant has non-empty storage

func (Keeper) SetStorageAndNotify

func (k Keeper) SetStorageAndNotify(ctx sdk.Context, entry agoric.KVEntry)

type ProposedChange

type ProposedChange struct {
	Path               string
	ValueFromLastBlock string
	NewValue           string
	LegacyEvents       bool
}

type Querier

type Querier struct {
	Keeper
}

Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper

func (Querier) CapData

/agoric.vstorage.Query/CapData returns data for a specified path, interpreted as CapData in a StreamCell (auto-promoting isolated CapData into a single-item StreamCell) and transformed as specified.

func (Querier) Children

/agoric.vstorage.Query/Children returns the list of path segments that exist immediately underneath a specified path, including those corresponding with "empty non-terminals" having children but no data of their own.

func (Querier) Data

/agoric.vstorage.Query/Data returns data for a specified path.

type StreamCell

type StreamCell struct {
	BlockHeight string   `json:"blockHeight"`
	Values      []string `json:"values"`
}

StreamCell is an envelope representing a sequence of values written at a path in a single block. It is persisted to storage as a { "blockHeight": "<digits>", "values": ["...", ...] } JSON text that off-chain consumers rely upon. Many of those consumers *also* rely upon the strings of "values" being valid JSON text, but we do not enforce that in this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL