datasources

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

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) GetTransactionByHash

func (d *BitcoinNodeDatasource) GetTransactionByHash(ctx context.Context, txHash chainhash.Hash) (*types.Transaction, error)

GetTransaction fetch transaction from Bitcoin node

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