keeper

package
v0.0.0-...-b8140f3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 22 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

Variables

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

2 ** 256 - 1

Functions

func NewQuerier

func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier

NewQuerier returns the function for handling queries routed to this module. It performs its own routing based on the first slash-separated URL path segment (e.g., URL path `/data/foo.bar` is a request for the value associated with vstorage path "foo.bar", and `/children/foo.bar` is a request for the child path segments immediately underneath vstorage path "foo.bar" which may be used to extend it to a vstorage path such as "foo.bar.baz").

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)

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)

func (*BatchingChangeManager) Track

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

type ChangeManager

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

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(storeKey storetypes.StoreKey) 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

ExportStorage fetches all storage

func (Keeper) ExportStorageFromPrefix

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

ExportStorageFromPrefix fetches storage only under the supplied pathPrefix.

func (Keeper) FlushChangeEvents

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

func (Keeper) GetChildren

func (k Keeper) GetChildren(ctx sdk.Context, path string) *types.Children

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) 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 children.

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)

func (Keeper) LegacySetStorageAndNotify

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

func (Keeper) NewChangeBatch

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

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