Documentation ¶
Index ¶
- Constants
- type Application
- func (app *Application) AddConsensusParamsUpdate(params types1.ConsensusParams, height int64)
- func (app *Application) AddValidatorSetUpdate(vsu abci.ValidatorSetUpdate, height int64)
- func (app *Application) ApplySnapshotChunk(_ context.Context, req *abci.RequestApplySnapshotChunk) (*abci.ResponseApplySnapshotChunk, error)
- func (app *Application) CheckTx(_ context.Context, req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error)
- func (app *Application) Close() error
- func (app *Application) FinalizeBlock(_ context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error)
- func (app *Application) Info(_ context.Context, req *abci.RequestInfo) (*abci.ResponseInfo, error)
- func (app *Application) InitChain(_ context.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error)
- func (app *Application) ListSnapshots(_ context.Context, req *abci.RequestListSnapshots) (*abci.ResponseListSnapshots, error)
- func (app *Application) LoadSnapshotChunk(_ context.Context, req *abci.RequestLoadSnapshotChunk) (*abci.ResponseLoadSnapshotChunk, error)
- func (app *Application) OfferSnapshot(_ context.Context, req *abci.RequestOfferSnapshot) (*abci.ResponseOfferSnapshot, error)
- func (app *Application) PrepareProposal(_ context.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error)
- func (app *Application) ProcessProposal(_ context.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error)
- func (app *Application) Query(_ context.Context, reqQuery *abci.RequestQuery) (*abci.ResponseQuery, error)
- func (app *Application) SetLastCommittedState(state State)
- type Config
- type ExecTxFunc
- type OptFunc
- func WithCommitVerification() OptFunc
- func WithConfig(config Config) OptFunc
- func WithDuplicateRequestDetection(enabled bool) OptFunc
- func WithExecTx(execTx ExecTxFunc) OptFunc
- func WithLogger(logger log.Logger) OptFunc
- func WithPrepareTxsFunc(prepareTxs PrepareTxsFunc) OptFunc
- func WithState(height int64, appHash []byte) OptFunc
- func WithValidatorSetUpdates(validatorSetUpdates map[int64]abci.ValidatorSetUpdate) OptFunc
- func WithVerifyTxFunc(verifyTx VerifyTxFunc) OptFunc
- type PrepareTxsFunc
- type SnapshotStore
- type State
- type StoreFactory
- type TxRecords
- type VerifyTxFunc
Constants ¶
const PreparePrefix = "prepare"
const ProtocolVersion uint64 = 0x12345678
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct { abci.BaseApplication // LastCommittedState is last state that was committed by Tenderdash and finalized with abci.FinalizeBlock() LastCommittedState State RetainBlocks int64 // blocks to retain after commit (via ResponseCommit.RetainHeight) // contains filtered or unexported fields }
Application is an example implementation of abci.Application.
func NewMemoryApp ¶
func NewMemoryApp(opts ...OptFunc) (*Application, error)
NewMemoryApp creates new Key/value store application that stores data to memory. Data is lost when the app stops. The application can be used for testing or as an example of ABCI implementation. It is possible to alter initial application configs with option functions.
func NewPersistentApp ¶
func NewPersistentApp(cfg Config, opts ...OptFunc) (*Application, error)
NewPersistentApp creates a new kvstore application that uses json file as persistent storage to store state.
func (*Application) AddConsensusParamsUpdate ¶
func (app *Application) AddConsensusParamsUpdate(params types1.ConsensusParams, height int64)
AddConsensusParamsUpdate schedules new consensus params update to be returned at `height` and used at `height+1`. `params` must be a final struct that should be passed to Tenderdash in ResponsePrepare/ProcessProposal at `height`.
func (*Application) AddValidatorSetUpdate ¶
func (app *Application) AddValidatorSetUpdate(vsu abci.ValidatorSetUpdate, height int64)
AddValidatorSetUpdate schedules new valiudator set update at some height
func (*Application) ApplySnapshotChunk ¶
func (app *Application) ApplySnapshotChunk(_ context.Context, req *abci.RequestApplySnapshotChunk) (*abci.ResponseApplySnapshotChunk, error)
ApplySnapshotChunk implements ABCI.
func (*Application) CheckTx ¶
func (app *Application) CheckTx(_ context.Context, req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error)
CheckTx implements ABCI
func (*Application) FinalizeBlock ¶
func (app *Application) FinalizeBlock(_ context.Context, req *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error)
FinalizeBlock implements ABCI
func (*Application) Info ¶
func (app *Application) Info(_ context.Context, req *abci.RequestInfo) (*abci.ResponseInfo, error)
Info implements ABCI
func (*Application) InitChain ¶
func (app *Application) InitChain(_ context.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error)
InitChain implements ABCI
func (*Application) ListSnapshots ¶
func (app *Application) ListSnapshots(_ context.Context, req *abci.RequestListSnapshots) (*abci.ResponseListSnapshots, error)
ListSnapshots implements ABCI.
func (*Application) LoadSnapshotChunk ¶
func (app *Application) LoadSnapshotChunk(_ context.Context, req *abci.RequestLoadSnapshotChunk) (*abci.ResponseLoadSnapshotChunk, error)
LoadSnapshotChunk implements ABCI.
func (*Application) OfferSnapshot ¶
func (app *Application) OfferSnapshot(_ context.Context, req *abci.RequestOfferSnapshot) (*abci.ResponseOfferSnapshot, error)
OfferSnapshot implements ABCI.
func (*Application) PrepareProposal ¶
func (app *Application) PrepareProposal(_ context.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error)
PrepareProposal implements ABCI
func (*Application) ProcessProposal ¶
func (app *Application) ProcessProposal(_ context.Context, req *abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error)
func (*Application) Query ¶
func (app *Application) Query(_ context.Context, reqQuery *abci.RequestQuery) (*abci.ResponseQuery, error)
Query returns an associated value or nil if missing.
func (*Application) SetLastCommittedState ¶
func (app *Application) SetLastCommittedState(state State)
SetLastCommittedState updates a last committed state
type Config ¶
type Config struct { // The directory with which state will be persisted in. Usually $HOME/.tendermint/data Dir string `toml:"dir"` // SnapshotInterval specifies the height interval at which the application // will take state sync snapshots. Defaults to 0 (disabled). SnapshotInterval uint64 `toml:"snapshot_interval"` // RetainBlocks specifies the number of recent blocks to retain. Defaults to // 0, which retains all blocks. Must be greater that PersistInterval, // SnapshotInterval and EvidenceAgeHeight. RetainBlocks int64 `toml:"retain_blocks"` // KeyType sets the curve that will be used by validators. // Options are ed25519 & secp256k1 KeyType string `toml:"key_type"` // PersistInterval specifies the height interval at which the application // will persist state to disk. Defaults to 1 (every height), setting this to // 0 disables state persistence. PersistInterval uint64 `toml:"persist_interval"` // ValidatorUpdates is a map of heights to validator names and their power, // and will be returned by the ABCI application. For example, the following // changes the power of validator01 and validator02 at height 1000: // // [validator_update.1000] // validator01 = 20 // validator02 = 10 // // Specifying height 0 returns the validator update during InitChain. The // application returns the validator updates as-is, i.e. removing a // validator must be done by returning it with power 0, and any validators // not specified are not changed. // // height <-> pubkey <-> voting power ValidatorUpdates map[string]map[string]string `toml:"validator_update"` // Add artificial delays to each of the main ABCI calls to mimic computation time // of the application PrepareProposalDelayMS uint64 `toml:"prepare_proposal_delay_ms"` ProcessProposalDelayMS uint64 `toml:"process_proposal_delay_ms"` CheckTxDelayMS uint64 `toml:"check_tx_delay_ms"` VoteExtensionDelayMS uint64 `toml:"vote_extension_delay_ms"` FinalizeBlockDelayMS uint64 `toml:"finalize_block_delay_ms"` // dash parameters ThesholdPublicKeyUpdate map[string]string `toml:"threshold_public_key_update"` QuorumHashUpdate map[string]string `toml:"quorum_hash_update"` ChainLockUpdates map[string]string `toml:"chainlock_updates"` PrivValServerType string `toml:"privval_server_type"` InitAppInitialCoreHeight uint32 `toml:"init_app_core_chain_locked_height"` }
Config allows for the setting of high level parameters for running the e2e Application KeyType and ValidatorUpdates must be the same for all nodes running the same application.
func DefaultConfig ¶
type ExecTxFunc ¶
ExecTxFunc executes the transaction against some state
type OptFunc ¶
type OptFunc func(app *Application) error
OptFunc is a function that can modify application configuration. Used when creating new application.
func WithCommitVerification ¶
func WithCommitVerification() OptFunc
WithCommitVerification enables commit verification
func WithConfig ¶
WithConfig provides Config to new Application
func WithDuplicateRequestDetection ¶
WithDuplicateRequestDetection makes it possible to disable duplicate request detection. (enabled by default)
func WithExecTx ¶
func WithExecTx(execTx ExecTxFunc) OptFunc
WithExecTx provides custom transaction executing function to the Application
func WithLogger ¶
WithLogger sets logger when creating Application
func WithPrepareTxsFunc ¶
func WithPrepareTxsFunc(prepareTxs PrepareTxsFunc) OptFunc
WithPrepareTxsFunc provides custom transaction modification function to the Application
func WithValidatorSetUpdates ¶
func WithValidatorSetUpdates(validatorSetUpdates map[int64]abci.ValidatorSetUpdate) OptFunc
WithValidatorSetUpdates defines initial validator set when creating Application
func WithVerifyTxFunc ¶
func WithVerifyTxFunc(verifyTx VerifyTxFunc) OptFunc
WithVerifyTxFunc provides custom transaction verification function to the Application
type PrepareTxsFunc ¶
type PrepareTxsFunc func(req abci.RequestPrepareProposal) ([]*abci.TxRecord, error)
PrepareTxsFunc prepares transactions, possibly adding and/or removing some of them
type SnapshotStore ¶
SnapshotStore stores state sync snapshots. Snapshots are stored simply as JSON files, and chunks are generated on-the-fly by splitting the JSON data into fixed-size chunks.
func NewSnapshotStore ¶
func NewSnapshotStore(dir string) (*SnapshotStore, error)
NewSnapshotStore creates a new snapshot store.
func (*SnapshotStore) Create ¶
func (s *SnapshotStore) Create(state State) (abci.Snapshot, error)
Create creates a snapshot of the given application state's key/value pairs.
func (*SnapshotStore) List ¶
func (s *SnapshotStore) List() ([]*abci.Snapshot, error)
List lists available snapshots.
func (*SnapshotStore) Prune ¶
func (s *SnapshotStore) Prune(n int) error
Prune removes old snapshots ensuring only the most recent n snapshots remain
type State ¶
type State interface { dbm.DB // Save writes full content of this state to some output Save(output io.Writer) error // Load loads state from some input Load(from io.Reader) error // Copy copies the state to dst Copy(dst State) error // Close closes the state and frees up resources Close() error // GetHeight returns height of the state GetHeight() int64 // IncrementHeight increments height by 1, but not lower than initial height. IncrementHeight() // SetRound sets consensus round for the state SetRound(int32) // GetRound returns consensus round defined for the state GetRound() int32 // GetAppHash returns app hash for the state. You need to call UpdateAppHash() beforehand. GetAppHash() tmbytes.HexBytes // UpdateAppHash regenerates apphash for the state. It accepts transactions and tx results from current round. // It is deterministic for a given state, txs and txResults. UpdateAppHash(lastCommittedState State, txs types1.Txs, txResults []*types.ExecTxResult) error }
State represents kvstore app state at some height. State can be committed or uncommitted. Caller of State methods should do proper concurrency locking (eg. mutexes)
type StoreFactory ¶
type StoreFactory interface { // Reader returns new io.ReadCloser to be used to read data from Reader() (io.ReadCloser, error) // Writer returns new io.WriteCloser to be used to write data to Writer() (io.WriteCloser, error) }
StoreFactory is a factory that offers a reader to read data from, or writer to write data to it. Not thread-safe - the caller should control concurrency.
func NewFileStore ¶
func NewFileStore(path string) StoreFactory
func NewMemStateStore ¶
func NewMemStateStore() StoreFactory
type TxRecords ¶ added in v1.0.0
Helper struct that controls size of added transactions
type VerifyTxFunc ¶
type VerifyTxFunc func(tx types.Tx, typ abci.CheckTxType) (abci.ResponseCheckTx, error)
VerifyTxFunc checks if transaction is correct