dummy

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2018 License: MIT Imports: 14 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 (
	ValidatorSetChangePrefix string = "val:"
)

Variables

This section is empty.

Functions

func InitDummy

func InitDummy(app *PersistentDummyApplication)

InitDummy initializes the dummy 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 []byte, power int64) []byte

func RandVal

func RandVal(i int) *types.Validator

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

func RandVals

func RandVals(cnt int) []*types.Validator

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 DummyApplication

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

func NewDummyApplication

func NewDummyApplication() *DummyApplication

func (*DummyApplication) CheckTx

func (app *DummyApplication) CheckTx(tx []byte) types.ResponseCheckTx

func (*DummyApplication) Commit

func (app *DummyApplication) Commit() types.ResponseCommit

func (*DummyApplication) DeliverTx

func (app *DummyApplication) DeliverTx(tx []byte) types.ResponseDeliverTx

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

func (*DummyApplication) Info

func (app *DummyApplication) Info(req types.RequestInfo) (resInfo types.ResponseInfo)

func (*DummyApplication) Query

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

type PersistentDummyApplication

type PersistentDummyApplication struct {

	// validator set
	ValUpdates []*types.Validator
	// contains filtered or unexported fields
}

func NewPersistentDummyApplication

func NewPersistentDummyApplication(dbDir string) *PersistentDummyApplication

func (*PersistentDummyApplication) BeginBlock

Track the block hash and header information

func (*PersistentDummyApplication) CheckTx

func (*PersistentDummyApplication) Commit

Commit will panic if InitChain was not called

func (*PersistentDummyApplication) DeliverTx

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

func (*PersistentDummyApplication) EndBlock

Update the validator set

func (*PersistentDummyApplication) Info

func (*PersistentDummyApplication) InitChain

Save the validators in the merkle tree

func (*PersistentDummyApplication) Query

func (*PersistentDummyApplication) SetLogger

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

func (*PersistentDummyApplication) SetOption

func (*PersistentDummyApplication) Validators

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

Jump to

Keyboard shortcuts

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