events

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Deadline = 5 * time.Minute
)

Functions

This section is empty.

Types

type Backend

type Backend interface {
	SubscribeNewEpochEvent(chan<- *generalTypes.MinimalEpochConsensusInfoV2) event.Subscription
	SubscribeNewVerifiedSlotInfoEvent(chan<- *generalTypes.SlotInfoWithStatus) event.Subscription
	SubscribeNewReorgInfoEvent(ch chan<- *generalTypes.Reorg) event.Subscription

	ConsensusInfoByEpochRange(fromEpoch uint64) ([]*generalTypes.MinimalEpochConsensusInfoV2, error)
	LatestEpoch() uint64
	LatestEpochInfo(ctx context.Context) (*generalTypes.MinimalEpochConsensusInfoV2, error)

	GetSlotStatus(ctx context.Context, slot uint64, hash common.Hash, requestFrom bool) generalTypes.Status
	VerifiedSlotInfos(fromSlot uint64) (map[uint64]*generalTypes.BlockStatus, error)
	LatestFinalizedSlot() uint64
	StepId(slot uint64) uint64
	LatestStepId() uint64
	VerifiedShardInfos(fromSlot uint64) (map[uint64]*generalTypes.MultiShardInfo, error)
}

type BlockHash added in v0.7.0

type BlockHash struct {
	Slot uint64      `json:"slot"`
	Hash common.Hash `json:"hash"`
}

type BlockStatus added in v0.7.0

type BlockStatus struct {
	BlockHash
	Status generalTypes.Status
}

type EventSystem

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

EventSystem creates subscriptions, processes events and broadcasts them to the subscription which match the subscription criteria.

func NewEventSystem

func NewEventSystem(backend Backend) *EventSystem

NewEventSystem creates a new manager that listens for event on the given mux, parses and filters them. It uses the all map to retrieve filter changes. The work loop holds its own index that is used to forward events to filters.

The returned manager has a loop that needs to be stopped with the Stop function or by stopping the given mux.

func (*EventSystem) SubscribeConsensusInfo

func (es *EventSystem) SubscribeConsensusInfo(consensusInfo chan *types.MinimalEpochConsensusInfoV2, epoch uint64) *Subscription

SubscribePendingTxs creates a subscription that writes transaction hashes for transactions that enter the transaction pool.

func (*EventSystem) SubscribeReorgInfo added in v0.7.0

func (es *EventSystem) SubscribeReorgInfo(reorgInfo chan *types.Reorg) *Subscription

SubscribeReorgInfo

func (*EventSystem) SubscribeVerifiedSlotInfo added in v0.7.0

func (es *EventSystem) SubscribeVerifiedSlotInfo(slotInfo chan *types.SlotInfoWithStatus) *Subscription

SubscribeVerifiedSlotInfo

type MockBackend

type MockBackend struct {
	ConsensusInfoFeed event.Feed

	ConsensusInfos []*eventTypes.MinimalEpochConsensusInfoV2

	CurEpoch uint64
	// contains filtered or unexported fields
}

func (*MockBackend) ConsensusInfoByEpochRange

func (b *MockBackend) ConsensusInfoByEpochRange(fromEpoch uint64) ([]*eventTypes.MinimalEpochConsensusInfoV2, error)

func (*MockBackend) GetSlotStatus added in v0.7.0

func (mb *MockBackend) GetSlotStatus(ctx context.Context, slot uint64, hash common.Hash, requestType bool) eventTypes.Status

func (*MockBackend) LatestEpoch added in v0.7.0

func (mb *MockBackend) LatestEpoch() uint64

func (*MockBackend) LatestEpochInfo added in v0.7.0

func (*MockBackend) LatestFinalizedSlot added in v0.7.0

func (mb *MockBackend) LatestFinalizedSlot() uint64

func (*MockBackend) LatestStepId added in v0.7.0

func (mb *MockBackend) LatestStepId() uint64

func (*MockBackend) StepId added in v0.7.0

func (mb *MockBackend) StepId(slot uint64) uint64

func (*MockBackend) SubscribeNewEpochEvent

func (b *MockBackend) SubscribeNewEpochEvent(ch chan<- *eventTypes.MinimalEpochConsensusInfoV2) event.Subscription

func (*MockBackend) SubscribeNewReorgInfoEvent added in v0.7.0

func (b *MockBackend) SubscribeNewReorgInfoEvent(ch chan<- *eventTypes.Reorg) event.Subscription

func (*MockBackend) SubscribeNewVerifiedSlotInfoEvent added in v0.7.0

func (b *MockBackend) SubscribeNewVerifiedSlotInfoEvent(ch chan<- *eventTypes.SlotInfoWithStatus) event.Subscription

func (*MockBackend) VerifiedShardInfos added in v0.7.0

func (mb *MockBackend) VerifiedShardInfos(fromSlot uint64) (map[uint64]*eventTypes.MultiShardInfo, error)

func (*MockBackend) VerifiedSlotInfos added in v0.7.0

func (mb *MockBackend) VerifiedSlotInfos(fromSlot uint64) (map[uint64]*eventTypes.BlockStatus, error)

type PublicFilterAPI

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

PublicFilterAPI offers support to create and manage filters. This will allow external clients to retrieve various information related to the Ethereum protocol such als blocks, transactions and logs.

func NewPublicFilterAPI

func NewPublicFilterAPI(backend Backend, timeout time.Duration) *PublicFilterAPI

NewPublicFilterAPI returns a new PublicFilterAPI instance.

func (*PublicFilterAPI) ConfirmPanBlockHashes added in v0.7.0

func (api *PublicFilterAPI) ConfirmPanBlockHashes(
	ctx context.Context,
	requests []*BlockHash,
) ([]*BlockStatus, error)

ConfirmPanBlockHashes should be used to get the confirmation about known state of Pandora block hashes

func (*PublicFilterAPI) ConfirmVanBlockHashes added in v0.7.0

func (api *PublicFilterAPI) ConfirmVanBlockHashes(
	ctx context.Context,
	requests []*BlockHash,
) (response []*BlockStatus, err error)

ConfirmVanBlockHashes should be used to get the confirmation about known state of Vanguard block hashes

func (*PublicFilterAPI) GetShardInfos added in v0.7.0

func (api *PublicFilterAPI) GetShardInfos(ctx context.Context) (response map[uint64]*generalTypes.MultiShardInfo, err error)

GetShardInfos is a debug api for getting latest shard infos from verified shard info db

func (*PublicFilterAPI) MinimalConsensusInfo

func (api *PublicFilterAPI) MinimalConsensusInfo(ctx context.Context, requestedEpoch uint64) (*rpc.Subscription, error)

MinimalConsensusInfo

func (*PublicFilterAPI) SteamConfirmedPanBlockHashes added in v0.7.0

func (api *PublicFilterAPI) SteamConfirmedPanBlockHashes(
	ctx context.Context,
	request *BlockHash,
) (*rpc.Subscription, error)

SteamConfirmedPanBlockHashes

type Subscription

type Subscription struct {
	ID rpc.ID
	// contains filtered or unexported fields
}

Subscription is created when the client registers itself for a particular event.

func (*Subscription) Err

func (sub *Subscription) Err() <-chan error

Err returns a channel that is closed when unsubscribed.

func (*Subscription) Unsubscribe

func (sub *Subscription) Unsubscribe()

Unsubscribe uninstalls the subscription from the event broadcast loop.

type Type

type Type byte

Type determines the kind of filter and is used to put the filter in to the correct bucket when added.

const (
	// UnknownSubscription indicates an unknown subscription type
	UnknownSubscription Type = iota

	// MinConsensusInfoSubscription
	MinConsensusInfoSubscription

	// VerifiedSlotInfoSubscription triggers when new slot is verified
	VerifiedSlotInfoSubscription

	ReorgInfoSubscription

	// LastSubscription keeps track of the last index
	LastIndexSubscription
)

Jump to

Keyboard shortcuts

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