emitter

package
v0.0.0-...-34d0e24 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SenderCountBufferSize = 20000
	PayloadIndexerSize    = 5000
)
View Source
const (
	TxTimeBufferSize    = 20000
	TxTurnPeriod        = 8 * time.Second
	TxTurnPeriodLatency = 1 * time.Second
	TxTurnNonces        = 32
)

Variables

View Source
var (
	ErrNotEnoughGasPower = errors.New("not enough gas power")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	VersionToPublish string

	Validator ValidatorConfig

	EmitIntervals EmitIntervals // event emission intervals

	MaxTxsPerAddress int

	MaxParents idx.Event

	// thresholds on GasLeft
	LimitedTpsThreshold uint64
	NoTxsThreshold      uint64
	EmergencyThreshold  uint64

	TxsCacheInvalidation time.Duration

	PrevEmittedEventFile FileConfig
	PrevBlockVotesFile   FileConfig
	PrevEpochVoteFile    FileConfig
}

Config is the configuration of events emitter.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configurations for the events emitter.

func FakeConfig

func FakeConfig(num idx.Validator) Config

FakeConfig returns the testing configurations for the events emitter.

type EmitIntervals

type EmitIntervals struct {
	Min                        time.Duration
	Max                        time.Duration
	Confirming                 time.Duration // emit time when there's no txs to originate, but at least 1 tx to confirm
	ParallelInstanceProtection time.Duration
	DoublesignProtection       time.Duration
}

EmitIntervals is the configuration of emit intervals.

func (EmitIntervals) RandomizeEmitTime

func (cfg EmitIntervals) RandomizeEmitTime(r *rand.Rand) EmitIntervals

RandomizeEmitTime and return new config

type Emitter

type Emitter struct {
	logger.Periodic
	// contains filtered or unexported fields
}

func NewEmitter

func NewEmitter(
	config Config,
	world World,
) *Emitter

NewEmitter creation.

func (*Emitter) EmitEvent

func (em *Emitter) EmitEvent() (*inter.EventPayload, error)

func (*Emitter) OnEventConfirmed

func (em *Emitter) OnEventConfirmed(he inter.EventI)

func (*Emitter) OnEventConnected

func (em *Emitter) OnEventConnected(e inter.EventPayloadI)

OnEventConnected tracks new events

func (*Emitter) OnNewEpoch

func (em *Emitter) OnNewEpoch(newValidators *pos.Validators, newEpoch idx.Epoch)

OnNewEpoch should be called after each epoch change, and on startup

func (*Emitter) Start

func (em *Emitter) Start()

Start starts event emission.

func (*Emitter) Stop

func (em *Emitter) Stop()

Stop stops event emission.

type External

type External interface {
	sync.Locker
	Reader

	Check(e *inter.EventPayload, parents inter.Events) error
	Process(*inter.EventPayload) error
	Broadcast(*inter.EventPayload)
	Build(*inter.MutableEventPayload, func()) error
	DagIndex() *vecmt.Index

	IsBusy() bool
	IsSynced() bool
	PeersNum() int
}

External world

type FileConfig

type FileConfig struct {
	Path     string
	SyncMode bool
}

type LlrReader

type LlrReader interface {
	GetLowestBlockToDecide() idx.Block
	GetLastBV(id idx.ValidatorID) *idx.Block
	GetBlockRecordHash(idx.Block) *hash.Hash
	GetBlockEpoch(idx.Block) idx.Epoch

	GetLowestEpochToDecide() idx.Epoch
	GetLastEV(id idx.ValidatorID) *idx.Epoch
	GetEpochRecordHash(epoch idx.Epoch) *hash.Hash
}

type Reader

type Reader interface {
	LlrReader
	GetLatestBlockIndex() idx.Block
	GetEpochValidators() (*pos.Validators, idx.Epoch)
	GetEvent(hash.Event) *inter.Event
	GetEventPayload(hash.Event) *inter.EventPayload
	GetLastEvent(epoch idx.Epoch, from idx.ValidatorID) *hash.Event
	GetHeads(idx.Epoch) hash.Events
	GetGenesisTime() inter.Timestamp
	GetRules() opera.Rules
}

Reader is a callback for getting events from an external storage.

type Signer

type Signer valkeystore.SignerI

aliases for mock generator

type TxPool

type TxPool interface {
	// Has returns an indicator whether txpool has a transaction cached with the
	// given hash.
	Has(hash common.Hash) bool
	// Pending should return pending transactions.
	// The slice should be modifiable by the caller.
	Pending(enforceTips bool) (map[common.Address]types.Transactions, error)

	// SubscribeNewTxsNotify should return an event subscription of
	// NewTxsNotify and send events to the given channel.
	SubscribeNewTxsNotify(chan<- evmcore.NewTxsNotify) notify.Subscription

	// Count returns the total number of transactions
	Count() int
}

type TxSigner

type TxSigner types.Signer

type ValidatorConfig

type ValidatorConfig struct {
	ID     idx.ValidatorID
	PubKey validatorpk.PubKey
}

type World

type World struct {
	External
	TxPool   TxPool
	Signer   valkeystore.SignerI
	TxSigner types.Signer
}

World is an emitter's environment

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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