executor

package
v1.73.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: BSD-3-Clause Imports: 24 Imported by: 17

Documentation

Overview

Package executor 实现执行器模块基类功能

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrStateDBRevertWithoutTx is returned by RevertSet when no transaction is
	// active. Undoing a write is only meaningful between Begin and Commit/Rollback:
	// outside a transaction Set writes directly to the block cache and the
	// previous value is no longer available.
	ErrStateDBRevertWithoutTx = errors.New("statedb: RevertSet called outside a transaction")
	// ErrStateDBEmptyKey is returned by RevertSet for a nil or empty state key.
	ErrStateDBEmptyKey = errors.New("statedb: RevertSet called with an empty key")
)

Functions

func AddMVCC

func AddMVCC(db dbm.KVDB, detail *types.BlockDetail) (kvlist []*types.KeyValue)

AddMVCC convert key value to mvcc kv data

func DelMVCC

func DelMVCC(db dbm.KVDB, detail *types.BlockDetail) (kvlist []*types.KeyValue)

DelMVCC convert key value to mvcc kv data

func DisableLog

func DisableLog()

DisableLog disable log

func GetStack added in v1.65.1

func GetStack() string

GetStack ...

func NewLocalDB

func NewLocalDB(cli queue.Client, api client.QueueProtocolAPI, readOnly bool) db.KVDB

NewLocalDB 创建一个新的LocalDB

func NewStateDB

func NewStateDB(client queue.Client, stateHash []byte, localdb db.KVDB, opt *StateDBOption) db.KV

NewStateDB new state db

func RegisterPlugin

func RegisterPlugin(name string, p plugin)

RegisterPlugin register plugin

func SetLogLevel

func SetLogLevel(level string)

SetLogLevel set log level

Types

type Executor

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

Executor executor struct

func New

func New(cfg *typ.Chain33Config) *Executor

New new executor

func (*Executor) Close

func (exec *Executor) Close()

Close close executor

func (*Executor) SetQueueClient

func (exec *Executor) SetQueueClient(qcli queue.Client)

SetQueueClient set client queue, for recv msg

func (*Executor) Wait

func (exec *Executor) Wait()

Wait Executor ready

type LocalDB

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

LocalDB 本地数据库,类似localdb,不加入区块链的状态。 数据库只读,不能落盘 数据的get set 主要经过 cache 如果需要进行list, 那么把get set 的内容加入到 后端数据库

func (*LocalDB) Begin

func (l *LocalDB) Begin()

Begin 开始一个事务

func (*LocalDB) Close

func (l *LocalDB) Close() error

Close 提交一个事务

func (*LocalDB) Commit

func (l *LocalDB) Commit() error

Commit 提交一个事务

func (*LocalDB) DisableRead

func (l *LocalDB) DisableRead()

DisableRead 禁止读取LocalDB数据库

func (*LocalDB) DisableWrite

func (l *LocalDB) DisableWrite()

DisableWrite 禁止写LocalDB数据库

func (*LocalDB) EnableRead

func (l *LocalDB) EnableRead()

EnableRead 启动读取LocalDB数据库

func (*LocalDB) EnableWrite

func (l *LocalDB) EnableWrite()

EnableWrite 启动写LocalDB数据库

func (*LocalDB) Get

func (l *LocalDB) Get(key []byte) ([]byte, error)

Get 获取key

func (*LocalDB) GetSetKeys

func (l *LocalDB) GetSetKeys() (keys []string)

GetSetKeys get state db set keys

func (*LocalDB) List

func (l *LocalDB) List(prefix, key []byte, count, direction int32) ([][]byte, error)

List 从数据库中查询数据列表

func (*LocalDB) PrefixCount

func (l *LocalDB) PrefixCount(prefix []byte) (count int64)

PrefixCount 从数据库中查询指定前缀的key的数量

func (*LocalDB) ResetCache added in v1.67.5

func (l *LocalDB) ResetCache()

ResetCache evm 使用

func (*LocalDB) Rollback

func (l *LocalDB) Rollback()

Rollback 回滚修改

func (*LocalDB) Set

func (l *LocalDB) Set(key []byte, value []byte) error

Set 获取key

func (*LocalDB) StartTx

func (l *LocalDB) StartTx()

StartTx reset state db keys

type StateDB

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

StateDB state db for store mavl

func (*StateDB) BatchGet

func (s *StateDB) BatchGet(keys [][]byte) (values [][]byte, err error)

BatchGet batch get keys from state db

func (*StateDB) Begin

func (s *StateDB) Begin()

Begin 开启内存事务处理

func (*StateDB) Commit

func (s *StateDB) Commit() error

Commit canche tx

func (*StateDB) Get

func (s *StateDB) Get(key []byte) ([]byte, error)

Get get value from state db

func (*StateDB) GetSetKeys

func (s *StateDB) GetSetKeys() (keys []string)

GetSetKeys get state db set keys

func (*StateDB) ResetCache added in v1.68.0

func (s *StateDB) ResetCache()

ResetCache evm 使用

func (*StateDB) RevertSet added in v1.73.0

func (s *StateDB) RevertSet(key []byte, originalValue []byte) error

RevertSet undoes one write that the current transaction performed on key and restores the value the key had before that write.

The invariant it maintains is the one the executor relies on: every key in GetSetKeys must also appear in the transaction receipt (see checkKV in execenv.go). A reverted write must therefore stop being reported unless some other write to the same key in this transaction survives:

  • exactly one recorded occurrence of key is dropped from the GetSetKeys list, so duplicates left by repeated Set calls are handled one write at a time;
  • the transaction cache is set to originalValue, so reads later in the same transaction observe the restored value without touching the block cache.

Writes must be reverted in LIFO order: originalValue is the value observed before the reverted write, so undoing an older write while a newer one survives would not describe the value left by the newest surviving write.

A nil originalValue means the key did not exist before the write. The tx cache then holds the nil sentinel: cacheDB.Get reports such an entry as types.ErrNotFound, so the key reads as absent, and because its last recorded occurrence was removed it no longer appears in GetSetKeys or in the receipt.

originalValue is supplied by the caller (the pre-write state it captured) rather than read from storage, because earlier writes of this transaction live only in the transaction cache. A key with no recorded write in this transaction is a no-op, making revert paths idempotent. A nil/empty key is rejected with ErrStateDBEmptyKey and calling outside a transaction with ErrStateDBRevertWithoutTx; no input causes a panic.

func (*StateDB) Rollback

func (s *StateDB) Rollback()

Rollback reset tx

func (*StateDB) Set

func (s *StateDB) Set(key []byte, value []byte) error

Set set key value to state db

func (*StateDB) StartTx

func (s *StateDB) StartTx()

StartTx reset state db keys

type StateDBOption

type StateDBOption struct {
	EnableMVCC bool
	Height     int64
}

StateDBOption state db option enable mvcc

Jump to

Keyboard shortcuts

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