common

package
v0.0.0-release-2024-04... Latest Latest
Warning

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

Go to latest
Published: Apr 2, 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")
	ErrorConsensusStart = errors.New("consensus not start yet")
)

Functions

func GetQuorum

func GetQuorum(consensusType string, N int) uint64

func NeedChangeEpoch

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

func ReadEpochState

func ReadEpochState(epochStore storage.Storage, key string) ([]byte, error)

func StoreEpochState

func StoreEpochState(epochStore storage.Storage, key string, value []byte) error

Types

type CommitEvent

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

type Config

type Config struct {
	RepoRoot                                    string
	Config                                      *repo.ConsensusConfig
	Logger                                      logrus.FieldLogger
	ConsensusType                               string
	ConsensusStorageType                        string
	PrivKey                                     *ecdsa.PrivateKey
	GenesisEpochInfo                            *rbft.EpochInfo
	Network                                     network.Network
	BlockSync                                   common.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
	GetBlockHeaderFunc                          func(height uint64) (*types.BlockHeader, error)
	GetAccountBalance                           func(address string) *big.Int
	GetAccountNonce                             func(address *types.Address) uint64
	EpochStore                                  storage.Storage
}

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 Option

type Option func(*Config)

func WithApplied

func WithApplied(height uint64) Option

func WithBlockSync

func WithBlockSync(blockSync common.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 WithEpochStore

func WithEpochStore(epochStore storage.Storage) Option

func WithGenesisDigest

func WithGenesisDigest(digest string) Option

func WithGenesisEpochInfo

func WithGenesisEpochInfo(genesisEpochInfo *rbft.EpochInfo) Option

func WithGetAccountBalanceFunc

func WithGetAccountBalanceFunc(f func(address string) *big.Int) Option

func WithGetAccountNonceFunc

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

func WithGetBlockHeaderFunc

func WithGetBlockHeaderFunc(f func(height uint64) (*types.BlockHeader, 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

type TxResp

type TxResp struct {
	Status   bool
	ErrorMsg string
}

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