emitter

package
v1.0.2-rc.6 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: MIT Imports: 40 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 PrevEmittedEventFile
}

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 int) 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

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 PrevEmittedEventFile

type PrevEmittedEventFile struct {
	Path     string
	SyncMode bool
}

type Reader

type Reader interface {
	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
	GetRecommendedGasPrice() *big.Int
}

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() (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