txscanner

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogToConsole

func LogToConsole(msg string)

func RebuildAvaiIndexes

func RebuildAvaiIndexes(clientsCount int, clientSleepTimes *map[int]int64) []int

func StartScanTx

func StartScanTx(txWatcher TxWatcher) error

开始扫描

Types

type SimpleTxWatcher

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

简单交易管理结构

func NewSimpleTxWatcher

func NewSimpleTxWatcher(endpoints []string, scanStartBlock uint64, scanInterval time.Duration, callback func(*TxInfo) error) *SimpleTxWatcher

构造一个新的简单tx管理结构(默认3秒钟扫描一次)

func (*SimpleTxWatcher) AddInterestedFrom

func (watcher *SimpleTxWatcher) AddInterestedFrom(from string)

添加关注的from address

func (*SimpleTxWatcher) AddInterestedTo

func (watcher *SimpleTxWatcher) AddInterestedTo(to string)

添加关注的to address

func (*SimpleTxWatcher) Callback

func (watcher *SimpleTxWatcher) Callback(tx *TxInfo) error

tx回调处理方法

func (*SimpleTxWatcher) GetEthClients

func (watcher *SimpleTxWatcher) GetEthClients() ([]*ethclient.Client, error)

func (*SimpleTxWatcher) GetScanInterval

func (watcher *SimpleTxWatcher) GetScanInterval() time.Duration

获取区块扫描间隔

func (*SimpleTxWatcher) GetScanStartBlock

func (watcher *SimpleTxWatcher) GetScanStartBlock() uint64

func (*SimpleTxWatcher) IsInterestedTx

func (watcher *SimpleTxWatcher) IsInterestedTx(from string, to string) bool

func (*SimpleTxWatcher) SetInfuraSecrets

func (watcher *SimpleTxWatcher) SetInfuraSecrets(secrets []string)

func (*SimpleTxWatcher) SetScanInterval

func (watcher *SimpleTxWatcher) SetScanInterval(interval time.Duration)

设置区块扫描间隔

type TxInfo

type TxInfo struct {
	TxHash            string
	BlockHash         string
	BlockNumber       *big.Int
	BlockUnixSecs     uint64
	From              string
	Gas               uint64
	GasPrice          *big.Int
	InputData         []byte
	Nonce             uint64
	To                string
	Value             *big.Int
	V                 []byte
	R                 []byte
	S                 []byte
	ChainID           *big.Int
	CallMethodID      string
	Status            uint64
	TransactionIndex  uint
	GasUsed           uint64
	CumulativeGasUsed uint64
	// contains filtered or unexported fields
}

tx相关信息

func (*TxInfo) JSON

func (tx *TxInfo) JSON() string

获取tx的json形式

func (*TxInfo) Logs

func (tx *TxInfo) Logs() []*types.Log

获取tx logs

type TxWatcher

type TxWatcher interface {
	//获取开始扫描的区块号
	GetScanStartBlock() uint64

	//获取节点地址
	GetEthClients() ([]*ethclient.Client, error)

	//是否是需要解析的tx
	IsInterestedTx(from string, to string) bool

	//tx回调处理方法
	Callback(tx *TxInfo) error

	//获取扫描间隔
	GetScanInterval() time.Duration
}

Jump to

Keyboard shortcuts

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