subscriber

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetQueryHash added in v0.0.2

func GetQueryHash(chainId *big.Int, query ethereum.FilterQuery) common.Hash

func GetQueryKey

func GetQueryKey(chainId *big.Int, query ethereum.FilterQuery) string

Types

type ChainSubscriber

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

ChainSubscriber implements Subscriber interface

func NewChainSubscriber

func NewChainSubscriber(c *ethclient.Client, storage SubscriberStorage) (*ChainSubscriber, error)

NewChainSubscriber .

func (*ChainSubscriber) FilterLogs

func (cs *ChainSubscriber) FilterLogs(ctx context.Context, q ethereum.FilterQuery) (logs []types.Log, err error)

func (*ChainSubscriber) FilterLogsWithChannel

func (cs *ChainSubscriber) FilterLogsWithChannel(ctx context.Context, q ethereum.FilterQuery, logsChan chan<- types.Log, watch bool, closeOnExit bool) (err error)

func (*ChainSubscriber) GetBlockConfirmationsOnSubscription added in v0.0.2

func (cs *ChainSubscriber) GetBlockConfirmationsOnSubscription() uint64

func (*ChainSubscriber) SetBlockConfirmationsOnSubscription added in v0.0.2

func (cs *ChainSubscriber) SetBlockConfirmationsOnSubscription(confirmations uint64)

func (*ChainSubscriber) SubscribeFilterLogs

func (cs *ChainSubscriber) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (sub ethereum.Subscription, err error)

func (*ChainSubscriber) SubscribeNewHead

func (cs *ChainSubscriber) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (sub ethereum.Subscription, err error)

SubscribeNewHead .

type MemoryStorage

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

func NewMemoryStorage

func NewMemoryStorage(chainId *big.Int) *MemoryStorage

func (*MemoryStorage) LatestBlockForQuery

func (s *MemoryStorage) LatestBlockForQuery(ctx context.Context, query ethereum.FilterQuery) (uint64, error)

func (*MemoryStorage) LatestLogForQuery

func (s *MemoryStorage) LatestLogForQuery(ctx context.Context, query ethereum.FilterQuery) (types.Log, error)

func (*MemoryStorage) SaveLatestBlockForQuery

func (s *MemoryStorage) SaveLatestBlockForQuery(ctx context.Context, query ethereum.FilterQuery, blockNum uint64) error

func (*MemoryStorage) SaveLatestLogForQuery

func (s *MemoryStorage) SaveLatestLogForQuery(ctx context.Context, query ethereum.FilterQuery, log types.Log) error

type RedisStorage

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

func NewRedisStorage

func NewRedisStorage(chainId *big.Int, pool redis.Pool) *RedisStorage

func (*RedisStorage) LatestBlockForQuery

func (s *RedisStorage) LatestBlockForQuery(ctx context.Context, query ethereum.FilterQuery) (uint64, error)

func (*RedisStorage) LatestLogForQuery

func (s *RedisStorage) LatestLogForQuery(ctx context.Context, query ethereum.FilterQuery) (types.Log, error)

func (*RedisStorage) QueryLock

func (s *RedisStorage) QueryLock(q ethereum.FilterQuery) sync.Locker

func (*RedisStorage) SaveLatestBlockForQuery

func (s *RedisStorage) SaveLatestBlockForQuery(ctx context.Context, query ethereum.FilterQuery, blockNum uint64) error

func (*RedisStorage) SaveLatestLogForQuery

func (s *RedisStorage) SaveLatestLogForQuery(ctx context.Context, query ethereum.FilterQuery, log types.Log) error

type Subscriber

type Subscriber interface {
	GetBlockConfirmationsOnSubscription() uint64
	SetBlockConfirmationsOnSubscription(confirmations uint64)
	SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
	SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
	FilterLogs(ctx context.Context, q ethereum.FilterQuery) (logs []types.Log, err error)
}

Subscriber represents a set of methods about chain subscription

type SubscriberStorage

type SubscriberStorage interface {
	LatestBlockForQuery(ctx context.Context, query ethereum.FilterQuery) (uint64, error)
	LatestLogForQuery(ctx context.Context, query ethereum.FilterQuery) (types.Log, error)

	SaveLatestBlockForQuery(ctx context.Context, query ethereum.FilterQuery, blockNum uint64) error
	SaveLatestLogForQuery(ctx context.Context, query ethereum.FilterQuery, log types.Log) error
}

Used only for function `SubscribeFilterlogs` and query.ToBlock == nil

Jump to

Keyboard shortcuts

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