Documentation
¶
Index ¶
- type HTTPServer
- type KVExecutor
- func (k *KVExecutor) ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight uint64, timestamp time.Time, ...) ([]byte, error)
- func (k *KVExecutor) FilterTxs(ctx context.Context, txs [][]byte, maxBytes, maxGas uint64, ...) ([]execution.FilterStatus, error)
- func (k *KVExecutor) GetExecutionInfo(ctx context.Context) (execution.ExecutionInfo, error)
- func (k *KVExecutor) GetStoreValue(ctx context.Context, key string) (string, bool)
- func (k *KVExecutor) GetTxs(ctx context.Context) ([][]byte, error)
- func (k *KVExecutor) InitChain(ctx context.Context, genesisTime time.Time, initialHeight uint64, ...) ([]byte, error)
- func (k *KVExecutor) InjectTx(tx []byte)
- func (k *KVExecutor) Rollback(ctx context.Context, height uint64) error
- func (k *KVExecutor) SetFinal(ctx context.Context, blockHeight uint64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer wraps a KVExecutor and provides an HTTP interface for it
func NewHTTPServer ¶
func NewHTTPServer(executor *KVExecutor, listenAddr string) *HTTPServer
NewHTTPServer creates a new HTTP server for the KVExecutor
type KVExecutor ¶
type KVExecutor struct {
// contains filtered or unexported fields
}
KVExecutor is a simple key-value store backed by go-datastore that implements the Executor interface for testing purposes. It uses a buffered channel as a mempool for transactions. It also includes fields to track genesis initialization persisted in the datastore.
func NewKVExecutor ¶
func NewKVExecutor(rootdir, dbpath string) (*KVExecutor, error)
NewKVExecutor creates a new instance of KVExecutor with initialized store and mempool channel.
func (*KVExecutor) ExecuteTxs ¶
func (k *KVExecutor) ExecuteTxs(ctx context.Context, txs [][]byte, blockHeight uint64, timestamp time.Time, prevStateRoot []byte) ([]byte, error)
ExecuteTxs processes each transaction assumed to be in the format "key=value". It updates the database accordingly using a batch and removes the executed transactions from the mempool. Invalid transactions are filtered out and logged, but execution continues.
func (*KVExecutor) FilterTxs ¶
func (k *KVExecutor) FilterTxs(ctx context.Context, txs [][]byte, maxBytes, maxGas uint64, hasForceIncludedTransaction bool) ([]execution.FilterStatus, error)
FilterTxs validates force-included transactions and applies size filtering. For KVExecutor, validates key=value format when force-included txs are present. KVExecutor doesn't track gas, so maxGas is ignored.
func (*KVExecutor) GetExecutionInfo ¶
func (k *KVExecutor) GetExecutionInfo(ctx context.Context) (execution.ExecutionInfo, error)
GetExecutionInfo returns execution layer parameters. For KVExecutor, returns MaxGas=0 indicating no gas-based filtering.
func (*KVExecutor) GetStoreValue ¶
GetStoreValue is a helper for the HTTP interface to retrieve the value for a key from the database. It searches across all block heights to find the latest value for the given key.
func (*KVExecutor) GetTxs ¶
func (k *KVExecutor) GetTxs(ctx context.Context) ([][]byte, error)
GetTxs retrieves available transactions from the mempool channel. It drains the channel in a non-blocking way.
func (*KVExecutor) InitChain ¶
func (k *KVExecutor) InitChain(ctx context.Context, genesisTime time.Time, initialHeight uint64, chainID string) ([]byte, error)
InitChain initializes the chain state with genesis parameters. It checks the database to see if genesis was already performed. If not, it computes the state root from the current DB state and persists genesis info.
func (*KVExecutor) InjectTx ¶
func (k *KVExecutor) InjectTx(tx []byte)
InjectTx adds a transaction to the mempool channel. Uses a non-blocking send to avoid blocking the caller if the channel is full.