kvstore

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ValidatorUpdatePrefix string = "val:"
	ValidatorKeyPrefix    string = "/val/"
)

Variables

View Source
var (
	AppVersion = "v0.0.0"
)

Functions

func InitKVStore

func InitKVStore(app *PersistentKVStoreApplication)

InitKVStore initializes the kvstore app with some data, which allows tests to pass and is fine as long as you don't make any tx that modify the validator state

func MakeValSetChangeTx

func MakeValSetChangeTx(pubkey crypto.PubKey, power int64) []byte

func RandVal

func RandVal(i int) abci.ValidatorUpdate

RandVal creates one random validator, with a key derived from the input value

func RandVals

func RandVals(cnt int) []abci.ValidatorUpdate

RandVals returns a list of cnt validators for initializing the application. Note that the keys are deterministically derived from the index in the array, while the power is random (Change this if not desired)

Types

type KVStoreApplication

type KVStoreApplication struct {
	abci.BaseApplication
	// contains filtered or unexported fields
}

func NewKVStoreApplication

func NewKVStoreApplication() *KVStoreApplication

func (*KVStoreApplication) CheckTx

func (*KVStoreApplication) Close

func (app *KVStoreApplication) Close() error

func (*KVStoreApplication) Commit

func (app *KVStoreApplication) Commit() (res abci.ResponseCommit)

func (*KVStoreApplication) DeliverTx

tx is either "key=value" or just arbitrary bytes

func (*KVStoreApplication) Info

func (app *KVStoreApplication) Info(req abci.RequestInfo) (resInfo abci.ResponseInfo)

func (*KVStoreApplication) Query

func (app *KVStoreApplication) Query(reqQuery abci.RequestQuery) (resQuery abci.ResponseQuery)

Returns an associated value or nil if missing.

type PersistentKVStoreApplication

type PersistentKVStoreApplication struct {

	// validator set
	ValSetChanges []abci.ValidatorUpdate
	// contains filtered or unexported fields
}

func NewPersistentKVStoreApplication

func NewPersistentKVStoreApplication(dbDir string) *PersistentKVStoreApplication

func (*PersistentKVStoreApplication) BeginBlock

Track the block hash and header information

func (*PersistentKVStoreApplication) CheckTx

func (*PersistentKVStoreApplication) Close

func (app *PersistentKVStoreApplication) Close() error

func (*PersistentKVStoreApplication) Commit

Commit will panic if InitChain was not called

func (*PersistentKVStoreApplication) DeliverTx

tx is either "val:pubkey!power" or "key=value" or just arbitrary bytes

func (*PersistentKVStoreApplication) EndBlock

Update the validator set

func (*PersistentKVStoreApplication) Info

func (*PersistentKVStoreApplication) InitChain

Save the validators in the merkle tree

func (*PersistentKVStoreApplication) Query

func (app *PersistentKVStoreApplication) Query(reqQuery abci.RequestQuery) (resQuery abci.ResponseQuery)

When path=/val and data={validator address}, returns the validator update (abci.ValidatorUpdate) varint encoded. For any other path, returns an associated value or nil if missing.

func (*PersistentKVStoreApplication) SetLogger

func (app *PersistentKVStoreApplication) SetLogger(l *slog.Logger)

func (*PersistentKVStoreApplication) SetOption

func (*PersistentKVStoreApplication) Validators

func (app *PersistentKVStoreApplication) Validators() (validators []abci.ValidatorUpdate)

type State

type State struct {
	Size    int64  `json:"size"`
	Height  int64  `json:"height"`
	AppHash []byte `json:"app_hash"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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