kvstore

package
v0.0.0-...-f968202 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

README

Dummy

There are two app's here: the DummyApplication and the PersistentDummyApplication.

DummyApplication

The DummyApplication is a simple merkle key-value store. Transactions of the form key=value are stored as key-value pairs in the tree. Transactions without an = sign set the value to the key. The app has no replay protection (other than what the mempool provides).

PersistentDummyApplication

The PersistentDummyApplication wraps the DummyApplication and provides two additional features:

  1. persistence of state across app restarts (using Tendermint's ABCI-Handshake mechanism)
  2. validator set changes

The state is persisted in leveldb along with the last block committed, and the Handshake allows any necessary blocks to be replayed. Validator set changes are effected using the following transaction format:

val:pubkey1/power1,addr2/power2,addr3/power3"

where power1 is the new voting power for the validator with pubkey1 (possibly a new one). There is no sybil protection against new validators joining. Validators can be removed by setting their power to 0.

Documentation

Index

Constants

View Source
const (
	WriteSet byte = 0x01
	WriteRem byte = 0x02
)

Transaction type bytes

View Source
const (
	PathDoc string = "/Users/b/Documents/"
)
View Source
const (
	ValidatorSetChangePrefix string = "val:"
)

Variables

This section is empty.

Functions

func Compare

func Compare(studentAdd string, projectAdd string) bool

func MakeValSetChangeTx

func MakeValSetChangeTx(pubkey []byte, power uint64) []byte

func SaveLastBlock

func SaveLastBlock(db dbm.DB, lastBlock LastBlockInfo)

Types

type LastBlockInfo

type LastBlockInfo struct {
	Height  uint64
	AppHash []byte
}

func LoadLastBlock

func LoadLastBlock(db dbm.DB) (lastBlock LastBlockInfo)

Get the last block from the db

type PersistentStorageApplication

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

func NewPersistentStorageApplication

func NewPersistentStorageApplication(dbDir string) *PersistentStorageApplication

func (*PersistentStorageApplication) BeginBlock

func (app *PersistentStorageApplication) BeginBlock(hash []byte, header *types.Header)

Track the block hash and header information

func (*PersistentStorageApplication) CheckTx

func (app *PersistentStorageApplication) CheckTx(tx []byte) types.Result

func (*PersistentStorageApplication) Commit

func (*PersistentStorageApplication) DeliverTx

func (app *PersistentStorageApplication) DeliverTx(tx []byte) types.Result

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

func (*PersistentStorageApplication) EndBlock

func (app *PersistentStorageApplication) EndBlock(height uint64) (resEndBlock types.ResponseEndBlock)

Update the validator set

func (*PersistentStorageApplication) Info

func (app *PersistentStorageApplication) Info() (resInfo types.ResponseInfo)

func (*PersistentStorageApplication) InitChain

func (app *PersistentStorageApplication) InitChain(validators []*types.Validator)

Save the validators in the merkle tree

func (*PersistentStorageApplication) Query

func (*PersistentStorageApplication) SetLogger

func (app *PersistentStorageApplication) SetLogger(l log.Logger)

func (*PersistentStorageApplication) SetOption

func (app *PersistentStorageApplication) SetOption(key string, value string) (log string)

func (*PersistentStorageApplication) Validators

func (app *PersistentStorageApplication) Validators() (validators []*types.Validator)

type StorageApplication

type StorageApplication struct {
	types.BaseApplication
	// contains filtered or unexported fields
}

func NewStorageApplication

func NewStorageApplication() *StorageApplication

func (*StorageApplication) CheckTx

func (app *StorageApplication) CheckTx(tx []byte) types.Result

func (*StorageApplication) Commit

func (app *StorageApplication) Commit() types.Result

func (*StorageApplication) DeliverTx

func (app *StorageApplication) DeliverTx(tx []byte) types.Result

tx is either "0x01|len(len(key))|len(key)|key|len(len(value))|len(value)|value" or "0x02|len(len(key))|len(key)|key|len(len(value))|len(value)|value"

func (*StorageApplication) Info

func (app *StorageApplication) Info() (resInfo types.ResponseInfo)

func (*StorageApplication) Query

func (app *StorageApplication) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery)

Jump to

Keyboard shortcuts

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