common

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LocalTxEvent = iota
	RemoteTxEvent
)

Variables

View Source
var (
	ErrorPreCheck  = errors.New("precheck failed")
	ErrorAddTxPool = errors.New("add txpool failed")
)

Functions

func NeedChangeEpoch

func NeedChangeEpoch(height uint64, epochInfo *rbft.EpochInfo) bool

Types

type AccountMeta

type AccountMeta struct {
	CommitNonce  uint64
	PendingNonce uint64
	TxCount      uint64
	Txs          []*TxInfo
	SimpleTxs    []*TxSimpleInfo
}

type BatchSimpleInfo

type BatchSimpleInfo struct {
	TxCount   uint64
	Txs       []*TxSimpleInfo
	Timestamp int64
}

type CommitEvent

type CommitEvent struct {
	Block                  *types.Block
	StateUpdatedCheckpoint *consensus.Checkpoint
}

type Config

type Config struct {
	RepoRoot                                    string
	EVMConfig                                   repo.EVM
	Config                                      *repo.ConsensusConfig
	Logger                                      logrus.FieldLogger
	ConsensusType                               string
	ConsensusStorageType                        string
	PrivKey                                     *ecdsa.PrivateKey
	SelfAccountAddress                          string
	GenesisEpochInfo                            *rbft.EpochInfo
	Network                                     network.Network
	BlockSync                                   block_sync.Sync
	TxPool                                      txpool.TxPool[types.Transaction, *types.Transaction]
	Applied                                     uint64
	Digest                                      string
	GenesisDigest                               string
	GetCurrentEpochInfoFromEpochMgrContractFunc func() (*rbft.EpochInfo, error)
	GetEpochInfoFromEpochMgrContractFunc        func(epoch uint64) (*rbft.EpochInfo, error)
	GetChainMetaFunc                            func() *types.ChainMeta
	GetBlockFunc                                func(height uint64) (*types.Block, error)
	GetAccountBalance                           func(address *types.Address) *big.Int
	GetAccountNonce                             func(address *types.Address) uint64
}

func GenerateConfig

func GenerateConfig(opts ...Option) (*Config, error)

type Logger

type Logger struct {
	logrus.FieldLogger
}

func (*Logger) Critical

func (lg *Logger) Critical(v ...any)

func (*Logger) Criticalf

func (lg *Logger) Criticalf(format string, v ...any)

func (*Logger) Notice

func (lg *Logger) Notice(v ...any)

func (*Logger) Noticef

func (lg *Logger) Noticef(format string, v ...any)

func (*Logger) Trace

func (lg *Logger) Trace(name string, stage string, content any)

Trace implements rbft.Logger.

type Meta

type Meta struct {
	TxCountLimit    uint64
	TxCount         uint64
	ReadyTxCount    uint64
	Batches         map[string]*BatchSimpleInfo
	MissingBatchTxs map[string]map[uint64]string
	Accounts        map[string]*AccountMeta
}

func MetaFromTxpool

func MetaFromTxpool(res *txpool.Meta[types.Transaction, *types.Transaction]) *Meta

type Option

type Option func(*Config)

func WithApplied

func WithApplied(height uint64) Option

func WithBlockSync

func WithBlockSync(blockSync block_sync.Sync) Option

func WithConfig

func WithConfig(repoRoot string, cfg *repo.ConsensusConfig) Option

func WithConsensusStorageType

func WithConsensusStorageType(consensusStorageType string) Option

func WithConsensusType

func WithConsensusType(typ string) Option

func WithDigest

func WithDigest(digest string) Option

func WithEVMConfig

func WithEVMConfig(c repo.EVM) Option

func WithGenesisDigest

func WithGenesisDigest(digest string) Option

func WithGenesisEpochInfo

func WithGenesisEpochInfo(genesisEpochInfo *rbft.EpochInfo) Option

func WithGetAccountBalanceFunc

func WithGetAccountBalanceFunc(f func(address *types.Address) *big.Int) Option

func WithGetAccountNonceFunc

func WithGetAccountNonceFunc(f func(address *types.Address) uint64) Option

func WithGetBlockFunc

func WithGetBlockFunc(f func(height uint64) (*types.Block, error)) Option

func WithGetChainMetaFunc

func WithGetChainMetaFunc(f func() *types.ChainMeta) Option

func WithGetCurrentEpochInfoFromEpochMgrContractFunc

func WithGetCurrentEpochInfoFromEpochMgrContractFunc(f func() (*rbft.EpochInfo, error)) Option

func WithGetEpochInfoFromEpochMgrContractFunc

func WithGetEpochInfoFromEpochMgrContractFunc(f func(epoch uint64) (*rbft.EpochInfo, error)) Option

func WithLogger

func WithLogger(logger logrus.FieldLogger) Option

func WithNetwork

func WithNetwork(net network.Network) Option

func WithPrivKey

func WithPrivKey(privKey *ecdsa.PrivateKey) Option

func WithSelfAccountAddress

func WithSelfAccountAddress(selfAccountAddress string) Option

type TxInfo

type TxInfo struct {
	Tx          *types.Transaction
	Local       bool
	LifeTime    int64
	ArrivedTime int64
}

type TxResp

type TxResp struct {
	Status   bool
	ErrorMsg string
}

type TxSimpleInfo

type TxSimpleInfo struct {
	Hash        string
	Nonce       uint64
	Size        int
	Local       bool
	LifeTime    int64
	ArrivedTime int64
}

type TxWithResp

type TxWithResp struct {
	Tx      *types.Transaction
	CheckCh chan *TxResp
	PoolCh  chan *TxResp
}

type UncheckedTxEvent

type UncheckedTxEvent struct {
	EventType int
	Event     any
}

UncheckedTxEvent represents misc event sent by local modules

Jump to

Keyboard shortcuts

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