bloomquery

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: LGPL-3.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartBloomHandlers

func StartBloomHandlers(shutdownChan chan bool, bloomRequests chan chan *Retrieval, chainDb dbwrapper.Database)

StartBloomHandlers starts a batch of goroutines to accept bloom bit database retrievals from possibly a range of filters and serving the data to satisfy.

Types

type Backend

type Backend interface {
	ChainDb() dbwrapper.Database
	GetBlock(ctx context.Context, fullHash common.Hash) *types.Block
	GetMainBranchBlock(height uint64) (*types.BlockHeader, error)
	GetLogs(ctx context.Context, blockHash common.Hash) [][]*types.Log
	BloomRequestsReceiver() chan chan *Retrieval
}

type Filter

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

Filter can be used to retrieve and filter logs.

func NewBlockFilter

func NewBlockFilter(backend Backend, block common.Hash, addresses []common.Address, topics [][]common.Hash) *Filter

NewBlockFilter creates a new filter which directly inspects the contents of a block to figure out whether it is interesting or not.

func NewRangeFilter

func NewRangeFilter(backend Backend, begin, end int64, addresses []common.Address, topics [][]common.Hash) *Filter

NewRangeFilter creates a new filter which uses a bloom filter on blocks to figure out whether a particular block is interesting or not.

func (*Filter) Logs

func (f *Filter) Logs(ctx context.Context) ([]*types.Log, error)

Logs searches the blockchain for matching log entries, returning all from the first block that contains matches, updating the start of the filter accordingly.

type Matcher

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

Matcher is a pipelined system of schedulers and logic matchers which perform binary AND/OR operations on the bit-streams, creating a stream of potential blocks to inspect for data content.

func NewMatcher

func NewMatcher(filters [][][]byte) *Matcher

NewMatcher creates a new pipeline for retrieving bloom bit streams and doing address and topic filtering on them. Setting a filter component to `nil` is allowed and will result in that filter rule being skipped (OR 0x11...1).

func (*Matcher) Start

func (m *Matcher) Start(ctx context.Context, db dbwrapper.Database, sectionIds []uint64, begin uint64, end uint64, results chan uint64) (*MatcherSession, error)

Start starts the matching process and returns a stream of bloom matches in a given range of blocks. If there are no more matches in the range, the result channel is closed.

type MatcherSession

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

MatcherSession is returned by a started matcher to be used as a terminator for the actively running matching operation.

func (*MatcherSession) Close

func (s *MatcherSession) Close()

Close stops the matching process and waits for all subprocesses to terminate before returning. The timeout may be used for graceful shutdown, allowing the currently running retrievals to complete before this time.

func (*MatcherSession) Error

func (s *MatcherSession) Error() error

Error returns any failure encountered during the matching session.

func (*MatcherSession) MultiGetQueryTaskLoop

func (s *MatcherSession) MultiGetQueryTaskLoop(ctx context.Context, bloomRequests chan chan *Retrieval)

type Retrieval

type Retrieval struct {
	Bit      uint
	Sections []uint64
	Bitsets  [][]byte

	Context context.Context
	Error   error
}

Retrieval represents a request for retrieval task assignments for a given bit with the given number of fetch elements, or a response for such a request. It can also have the actual results set to be used as a delivery data struct.

The contest and error fields are used by the light client to terminate matching early if an error is encountered on some path of the pipeline.

Jump to

Keyboard shortcuts

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