fetcher

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainFetch

type ChainFetch struct {
	Client EthClient
	// contains filtered or unexported fields
}

ChainFetch the real implementation

func NewChainFetch

func NewChainFetch() (*ChainFetch, error)

NewChainFetch new ChainFetch instance

func (*ChainFetch) FetchABlock

func (cf *ChainFetch) FetchABlock(blockNumber *big.Int) (*types.BLockDetail, error)

FetchABlock fetch a block by block number

func (*ChainFetch) GetLatestBlock

func (cf *ChainFetch) GetLatestBlock() (*big.Int, error)

GetLatestBlock get latest known block by geth node

func (*ChainFetch) IpcUpdated

func (cf *ChainFetch) IpcUpdated()

IpcUpdated no need to implement IpcSubscriber interface Let indexer update me

func (*ChainFetch) RealtimeFetch

func (cf *ChainFetch) RealtimeFetch(ch chan<- *types.BLockDetail)

RealtimeFetch fetch data from blockchain

func (*ChainFetch) TransactionByHash

func (cf *ChainFetch) TransactionByHash(txHash string) (*types.TransactionExtra, error)

TransactionByHash query geth node to get addtional data of tx

type EthClient

type EthClient interface {
	SubscribeNewHead(ctx context.Context, ch chan<- *gethtypes.Header) (ethereum.Subscription, error)
	BlockByNumber(ctx context.Context, number *big.Int) (*gethtypes.Block, error)
	TransactionSender(ctx context.Context, tx *gethtypes.Transaction, block common.Hash, index uint) (common.Address, error)
	HeaderByNumber(ctx context.Context, number *big.Int) (*gethtypes.Header, error)
	TransactionReceipt(ctx context.Context, txHash common.Hash) (*gethtypes.Receipt, error)
	TransactionByHash(ctx context.Context, hash common.Hash) (*gethtypes.Transaction, bool, error)
	Close()
}

EthClient the Client of geth

type Fetch

type Fetch interface {
	RealtimeFetch(ch chan<- *types.BLockDetail)
	FetchABlock(blockNumber *big.Int) (*types.BLockDetail, error)
	GetLatestBlock() (*big.Int, error)
	TransactionByHash(txHash string) (*types.TransactionExtra, error)
}

Fetch the interface to interact with blockchain

Jump to

Keyboard shortcuts

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