datasources

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: GPL-3.0 Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitcoinNodeDatasource

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

BitcoinNodeDatasource fetch data from Bitcoin node for Bitcoin Indexer

func NewBitcoinNode

func NewBitcoinNode(btcclient *rpcclient.Client) *BitcoinNodeDatasource

NewBitcoinNode create new BitcoinNodeDatasource with Bitcoin Core RPC Client

func (*BitcoinNodeDatasource) Fetch

func (d *BitcoinNodeDatasource) Fetch(ctx context.Context, from, to int64) ([]*types.Block, error)

Fetch polling blocks from Bitcoin node

  • from: block height to start fetching, if -1, it will start from genesis block
  • to: block height to stop fetching, if -1, it will fetch until the latest block

func (*BitcoinNodeDatasource) FetchAsync

func (d *BitcoinNodeDatasource) FetchAsync(ctx context.Context, from, to int64, ch chan<- []*types.Block) (*subscription.ClientSubscription[[]*types.Block], error)

FetchAsync polling blocks from Bitcoin node asynchronously (non-blocking)

  • from: block height to start fetching, if -1, it will start from genesis block
  • to: block height to stop fetching, if -1, it will fetch until the latest block

func (*BitcoinNodeDatasource) GetBlockHeader

func (d *BitcoinNodeDatasource) GetBlockHeader(ctx context.Context, height int64) (types.BlockHeader, error)

GetBlockHeader fetch block header from Bitcoin node

func (*BitcoinNodeDatasource) GetRawTransactionAndHeightByTxHash added in v0.2.7

func (d *BitcoinNodeDatasource) GetRawTransactionAndHeightByTxHash(ctx context.Context, txHash chainhash.Hash) (*wire.MsgTx, int64, error)

GetTransaction fetch transaction from Bitcoin node

func (*BitcoinNodeDatasource) GetRawTransactionByTxHash added in v0.4.0

func (d *BitcoinNodeDatasource) GetRawTransactionByTxHash(ctx context.Context, txHash chainhash.Hash) (*wire.MsgTx, error)

func (BitcoinNodeDatasource) Name

func (p BitcoinNodeDatasource) Name() string

type Datasource

type Datasource[T any] interface {
	Name() string
	Fetch(ctx context.Context, from, to int64) ([]T, error)
	FetchAsync(ctx context.Context, from, to int64, ch chan<- []T) (*subscription.ClientSubscription[[]T], error)
	GetBlockHeader(ctx context.Context, height int64) (types.BlockHeader, error)
}

Datasource is an interface for indexer data sources.

Jump to

Keyboard shortcuts

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