Documentation
¶
Index ¶
- type Accounts
- type BlockProcessor
- func (bp *BlockProcessor) AccountInfo(ctx context.Context, db sql.DB, identifier *ktypes.AccountID, pending bool) (balance *big.Int, nonce int64, err error)
- func (bp *BlockProcessor) BlockExecutionStatus() *ktypes.BlockExecutionStatus
- func (bp *BlockProcessor) BroadcastVoteIDTx(ctx context.Context, db sql.DB) error
- func (bp *BlockProcessor) CheckTx(ctx context.Context, ntx *types.Tx, height int64, blockTime time.Time, ...) error
- func (bp *BlockProcessor) Close() error
- func (bp *BlockProcessor) Commit(ctx context.Context, req *ktypes.CommitRequest) error
- func (bp *BlockProcessor) ConsensusParams() *ktypes.NetworkParameters
- func (bp *BlockProcessor) ExecuteBlock(ctx context.Context, req *ktypes.BlockExecRequest, syncing bool) (blkResult *ktypes.BlockExecResult, err error)
- func (bp *BlockProcessor) GetMigrationMetadata(ctx context.Context) (*ktypes.MigrationMetadata, error)
- func (bp *BlockProcessor) GetValidators() []*ktypes.Validator
- func (bp *BlockProcessor) HasEvents() bool
- func (bp *BlockProcessor) Height(ctx context.Context, db sql.Executor) (int64, error)
- func (bp *BlockProcessor) InitChain(ctx context.Context) (int64, []byte, error)
- func (bp *BlockProcessor) NumAccounts(ctx context.Context, db sql.Executor) (int64, error)
- func (bp *BlockProcessor) PrepareProposal(ctx context.Context, txs []*types.Tx) (finalTxs []*ktypes.Transaction, invalidTxs []*ktypes.Transaction, err error)
- func (bp *BlockProcessor) PrepareValidatorVoteIDTx(ctx context.Context, db sql.DB) (*types.Transaction, []*types.UUID, error)
- func (bp *BlockProcessor) Price(ctx context.Context, dbTx sql.DB, tx *ktypes.Transaction) (*big.Int, error)
- func (bp *BlockProcessor) Rollback(ctx context.Context, height int64, appHash ktypes.Hash) error
- func (bp *BlockProcessor) SetCallbackFns(broadcastFn BroadcastTxFn, addPeer, removePeer func(string) error)
- func (bp *BlockProcessor) StateHashes() *StateHashes
- func (bp *BlockProcessor) SubscribeValidators() <-chan []*ktypes.Validator
- func (bp *BlockProcessor) UpdateStats(delectCnt int64)
- type BlockStore
- type BroadcastTxFn
- type DB
- type EventStore
- type MigratorModule
- type SnapshotModule
- type StateHashes
- type TxApp
- type ValidatorModule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockProcessor ¶
type BlockProcessor struct {
// contains filtered or unexported fields
}
shouldn't be generally concerned with the role. maybe role is needed for broadcasting eventstore events to the leader.
func NewBlockProcessor ¶
func NewBlockProcessor(ctx context.Context, db DB, txapp TxApp, accounts Accounts, vs ValidatorModule, sp SnapshotModule, es EventStore, migrator MigratorModule, bs BlockStore, genesisCfg *config.GenesisConfig, signer auth.Signer, logger log.Logger) (*BlockProcessor, error)
func (*BlockProcessor) AccountInfo ¶
func (*BlockProcessor) BlockExecutionStatus ¶
func (bp *BlockProcessor) BlockExecutionStatus() *ktypes.BlockExecutionStatus
Used by the rpc server to get the execution status of the block being processed. end_time is not set if the block is still being processed.
func (*BlockProcessor) BroadcastVoteIDTx ¶
func (*BlockProcessor) Close ¶
func (bp *BlockProcessor) Close() error
func (*BlockProcessor) Commit ¶
func (bp *BlockProcessor) Commit(ctx context.Context, req *ktypes.CommitRequest) error
Commit method commits the block to the blockstore and postgres database. It also updates the txIndexer and mempool with the transactions in the block.
func (*BlockProcessor) ConsensusParams ¶
func (bp *BlockProcessor) ConsensusParams() *ktypes.NetworkParameters
func (*BlockProcessor) ExecuteBlock ¶
func (bp *BlockProcessor) ExecuteBlock(ctx context.Context, req *ktypes.BlockExecRequest, syncing bool) (blkResult *ktypes.BlockExecResult, err error)
func (*BlockProcessor) GetMigrationMetadata ¶
func (bp *BlockProcessor) GetMigrationMetadata(ctx context.Context) (*ktypes.MigrationMetadata, error)
func (*BlockProcessor) GetValidators ¶
func (bp *BlockProcessor) GetValidators() []*ktypes.Validator
func (*BlockProcessor) HasEvents ¶
func (bp *BlockProcessor) HasEvents() bool
func (*BlockProcessor) Height ¶
Height is provided to obtain the current height atomically with a call to another method such as AccountInfo via a single database transaction.
func (*BlockProcessor) InitChain ¶
InitChain initializes the node with the genesis state. This included initializing the votestore with the genesis validators, accounts with the genesis allocations and the chain meta store with the genesis network parameters. This is called only once when the node is bootstrapping for the first time.
func (*BlockProcessor) NumAccounts ¶
func (*BlockProcessor) PrepareProposal ¶
func (bp *BlockProcessor) PrepareProposal(ctx context.Context, txs []*types.Tx) (finalTxs []*ktypes.Transaction, invalidTxs []*ktypes.Transaction, err error)
This function enforces proper nonce ordering, validates transactions, and ensures that consensus limits such as the maximum block size, maxVotesPerTx are met. It also adds validator vote transactions for events observed by the leader. This function is used exclusively by the leader node to prepare the proposal block.
func (*BlockProcessor) PrepareValidatorVoteIDTx ¶
func (bp *BlockProcessor) PrepareValidatorVoteIDTx(ctx context.Context, db sql.DB) (*types.Transaction, []*types.UUID, error)
func (*BlockProcessor) Price ¶
func (bp *BlockProcessor) Price(ctx context.Context, dbTx sql.DB, tx *ktypes.Transaction) (*big.Int, error)
func (*BlockProcessor) SetCallbackFns ¶
func (bp *BlockProcessor) SetCallbackFns(broadcastFn BroadcastTxFn, addPeer, removePeer func(string) error)
func (*BlockProcessor) StateHashes ¶
func (bp *BlockProcessor) StateHashes() *StateHashes
func (*BlockProcessor) SubscribeValidators ¶
func (bp *BlockProcessor) SubscribeValidators() <-chan []*ktypes.Validator
SubscribeValidators creates and returns a new channel on which the current validator set will be sent for each block Commit. The receiver will miss updates if they are unable to receive fast enough. This should generally be used after catch-up is complete, and only called once by the receiving goroutine rather than repeatedly in a loop, for instance. The slice should not be modified by the receiver.
func (*BlockProcessor) UpdateStats ¶
func (bp *BlockProcessor) UpdateStats(delectCnt int64)
type BlockStore ¶
type BroadcastTxFn ¶
type DB ¶
type DB interface { sql.TxMaker // for out-of-consensus writes e.g. setup and meta table writes sql.PreparedTxMaker sql.ReadTxMaker sql.SnapshotTxMaker sql.DelayedReadTxMaker }
DB is the interface for the main SQL database. All queries must be executed from within a transaction. A DB can create read transactions or the special two-phase outer write transaction.
type EventStore ¶
type EventStore interface { // GetUnbroadcastedEvents filters out the events observed by the validator // that are not previously broadcasted. GetUnbroadcastedEvents(ctx context.Context) ([]*ktypes.UUID, error) // MarkBroadcasted marks list of events as broadcasted. MarkBroadcasted(ctx context.Context, ids []*ktypes.UUID) error // HasEvents return true if there are any events to be broadcasted HasEvents() bool // records the events for which the resolutions have been created. UpdateStats(deleteCnt int64) }
EventStore allows the BlockProcessor to read events from the event store.
type MigratorModule ¶
type MigratorModule interface { NotifyHeight(ctx context.Context, block *common.BlockContext, db migrations.Database, tx sql.Executor) error StoreChangesets(height int64, changes <-chan any) error PersistLastChangesetHeight(ctx context.Context, tx sql.Executor, height int64) error GetMigrationMetadata(ctx context.Context, status ktypes.MigrationStatus) (*ktypes.MigrationMetadata, error) }
type SnapshotModule ¶
type SnapshotModule interface { // Lists all the available snapshots in the snapshotstore and returns the snapshot metadata ListSnapshots() []*snapshotter.Snapshot // Returns the snapshot chunk of index chunkId at a given height LoadSnapshotChunk(height uint64, format uint32, chunkID uint32) ([]byte, error) // CreateSnapshot creates a snapshot of the current state. CreateSnapshot(ctx context.Context, height uint64, snapshotID string, schemas, excludedTables []string, excludeTableData []string) error // IsSnapshotDue returns true if a snapshot is due at the given height. IsSnapshotDue(height uint64) bool Enabled() bool }
SnapshotModule is an interface for a struct that implements snapshotting
type StateHashes ¶
type StateHashes struct {
// contains filtered or unexported fields
}
func (*StateHashes) String ¶
func (sh *StateHashes) String() string
type TxApp ¶
type TxApp interface { Begin(ctx context.Context, height int64) error Execute(ctx *common.TxContext, db sql.DB, tx *ktypes.Transaction) *txapp.TxResponse Finalize(ctx context.Context, db sql.DB, block *common.BlockContext) (approvedJoins, expiredJoins []*ktypes.AccountID, err error) Commit() error Rollback() GenesisInit(ctx context.Context, db sql.DB, genesisConfig *config.GenesisConfig, chain *common.ChainContext) error ApplyMempool(ctx *common.TxContext, db sql.DB, tx *ktypes.Transaction) error Price(ctx context.Context, dbTx sql.DB, tx *ktypes.Transaction, chainContext *common.ChainContext) (*big.Int, error) AccountInfo(ctx context.Context, dbTx sql.DB, identifier *ktypes.AccountID, pending bool) (balance *big.Int, nonce int64, err error) NumAccounts(ctx context.Context, dbTx sql.Executor) (int64, error) }