chain

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

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

Chain exposes methods for retrieval of chain data

func NewChain

func NewChain(cl client.Client) *Chain

NewChain creates a new Chain struct

func (*Chain) GetBlock

func (c *Chain) GetBlock(blockHash types.Hash) (*types.SignedBlock, error)

GetBlock returns the header and body of the relay chain block with the given hash

func (*Chain) GetBlockHash

func (c *Chain) GetBlockHash(blockNumber uint64) (types.Hash, error)

GetBlockHash returns the block hash for a specific block height

func (*Chain) GetBlockHashLatest

func (c *Chain) GetBlockHashLatest() (types.Hash, error)

GetBlockHashLatest returns the latest block hash

func (*Chain) GetBlockLatest

func (c *Chain) GetBlockLatest() (*types.SignedBlock, error)

GetBlockLatest returns the header and body of the latest relay chain block

func (*Chain) GetFinalizedHead

func (c *Chain) GetFinalizedHead() (types.Hash, error)

GetFinalizedHead returns the hash of the last finalized block in the canon chain

func (*Chain) GetHeader

func (c *Chain) GetHeader(blockHash types.Hash) (*types.Header, error)

GetHeader retrieves the header for the specific block

func (*Chain) GetHeaderLatest

func (c *Chain) GetHeaderLatest() (*types.Header, error)

GetHeaderLatest retrieves the header of the latest block

func (*Chain) SubscribeFinalizedHeads

func (c *Chain) SubscribeFinalizedHeads() (*FinalizedHeadsSubscription, error)

SubscribeFinalizedHeads subscribes the best finalized headers, returning a subscription that will receive server notifications containing the Header.

func (*Chain) SubscribeNewHeads

func (c *Chain) SubscribeNewHeads() (*NewHeadsSubscription, error)

SubscribeNewHeads subscribes the best headers, returning a subscription that will receive server notifications containing the Header.

type FinalizedHeadsSubscription

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

FinalizedHeadsSubscription is a subscription established through one of the Client's subscribe methods.

func (*FinalizedHeadsSubscription) Chan

func (s *FinalizedHeadsSubscription) Chan() <-chan types.Header

Chan returns the subscription channel.

The channel is closed when Unsubscribe is called on the subscription.

func (*FinalizedHeadsSubscription) Err

func (s *FinalizedHeadsSubscription) Err() <-chan error

Err returns the subscription error channel. The intended use of Err is to schedule resubscription when the client connection is closed unexpectedly.

The error channel receives a value when the subscription has ended due to an error. The received error is nil if Close has been called on the underlying client and no other error has occurred.

The error channel is closed when Unsubscribe is called on the subscription.

func (*FinalizedHeadsSubscription) Unsubscribe

func (s *FinalizedHeadsSubscription) Unsubscribe()

Unsubscribe unsubscribes the notification and closes the error channel. It can safely be called more than once.

type NewHeadsSubscription

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

NewHeadsSubscription is a subscription established through one of the Client's subscribe methods.

func (*NewHeadsSubscription) Chan

func (s *NewHeadsSubscription) Chan() <-chan types.Header

Chan returns the subscription channel.

The channel is closed when Unsubscribe is called on the subscription.

func (*NewHeadsSubscription) Err

func (s *NewHeadsSubscription) Err() <-chan error

Err returns the subscription error channel. The intended use of Err is to schedule resubscription when the client connection is closed unexpectedly.

The error channel receives a value when the subscription has ended due to an error. The received error is nil if Close has been called on the underlying client and no other error has occurred.

The error channel is closed when Unsubscribe is called on the subscription.

func (*NewHeadsSubscription) Unsubscribe

func (s *NewHeadsSubscription) Unsubscribe()

Unsubscribe unsubscribes the notification and closes the error channel. It can safely be called more than once.

Jump to

Keyboard shortcuts

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