watcher

package
v0.6.9 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReqStrBlockCount = `{"jsonrpc": "1.0", "id":"zeniqsmart", "method": "getblockcount", "params": [] }`
	ReqStrBlockHash  = `{"jsonrpc": "1.0", "id":"zeniqsmart", "method": "getblockhash", "params": [%d] }`
	//verbose = 2, show all txs rawdata
	ReqStrBlock    = `{"jsonrpc": "1.0", "id":"zeniqsmart", "method": "getblock", "params": ["%s",2] }`
	ReqStrTx       = `{"jsonrpc": "1.0", "id":"zeniqsmart", "method": "getrawtransaction", "params": ["%s", true, "%s"] }`
	ReqStrCC       = `{"jsonrpc": "1.0", "id":"zeniqsmart", "method": "crosschain", "params": ["%d", "%d"] }`
	ReqStrEpochs   = `{"jsonrpc": "2.0", "method": "sbch_getEpochs", "params": ["%s","%s"], "id":1}`
	ReqStrCCEpochs = `{"jsonrpc": "2.0", "method": "sbch_getCCEpochs", "params": ["%s","%s"], "id":1}`
	ReqSmartHeight = `{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id":1}`
)
View Source
const (
	NumBlocksToClearMemory = 1000
	WaitingBlockDelayTime  = 2
)

Variables

This section is empty.

Functions

func DO_getCC

func DO_getCC(first, last int64, respData []byte) (*ccrpc.CCrpcEpoch, error)

Types

type RpcClientImp

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

func NewRpcClient

func NewRpcClient(url, user, password, contentType string, logger log.Logger) *RpcClientImp

func (*RpcClientImp) FetchCC

func (client *RpcClientImp) FetchCC(first, last int64) *ccrpc.CCrpcEpoch

func (*RpcClientImp) GetBlockByHeight

func (client *RpcClientImp) GetBlockByHeight(height int64, retry bool) *watcher.BCHBlock

func (*RpcClientImp) GetBlockHash

func (client *RpcClientImp) GetBlockHash(height int64) (string, error)

**for tool

func (*RpcClientImp) GetBlockInfo

func (client *RpcClientImp) GetBlockInfo(hash string) (*watcher.BlockInfo, error)

func (*RpcClientImp) GetCCEpochs

func (client *RpcClientImp) GetCCEpochs(start, end uint64) []*crosschain.CCEpoch

func (*RpcClientImp) GetEpochs

func (client *RpcClientImp) GetEpochs(start, end uint64) []*staking.Epoch

func (*RpcClientImp) GetMainnetHeight

func (client *RpcClientImp) GetMainnetHeight() (height int64)

func (*RpcClientImp) GetTxInfo

func (client *RpcClientImp) GetTxInfo(hash string, blockhash string) (*watcher.TxInfo, error)

func (*RpcClientImp) IsConnected

func (client *RpcClientImp) IsConnected() bool

func (*RpcClientImp) NetworkSmartHeight

func (client *RpcClientImp) NetworkSmartHeight() (height int64)

type Watcher

type Watcher struct {
	EpochChan chan *stake.Epoch

	CCEpochChan chan *crosschain.CCEpoch
	// contains filtered or unexported fields
}

A watcher watches the new blocks generated on bitcoin cash's mainnet, and outputs epoch information through a channel

func NewWatcher

func NewWatcher(logger log.Logger, lastHeight, lastCCEpochEndHeight int64,
	lastKnownEpochNum int64, chainConfig *param.ChainConfig, rpcclient types.RpcClient) *Watcher

func (*Watcher) CheckMainnet

func (watcher *Watcher) CheckMainnet()

func (*Watcher) ClearOldData

func (watcher *Watcher) ClearOldData()

func (*Watcher) GetCurrEpoch

func (watcher *Watcher) GetCurrEpoch() *stake.Epoch

func (*Watcher) GetCurrMainnetBlockTimestamp

func (watcher *Watcher) GetCurrMainnetBlockTimestamp() int64

func (*Watcher) GetEpochList

func (watcher *Watcher) GetEpochList() []*stake.Epoch

func (*Watcher) NetworkSmartHeight

func (watcher *Watcher) NetworkSmartHeight() int64

func (*Watcher) SetNumBlocksInEpoch

func (watcher *Watcher) SetNumBlocksInEpoch(n int64)

func (*Watcher) SetNumBlocksToClearMemory

func (watcher *Watcher) SetNumBlocksToClearMemory(n int)

func (*Watcher) SetWaitingBlockDelayTime

func (watcher *Watcher) SetWaitingBlockDelayTime(n int)

func (*Watcher) WatcherMain

func (watcher *Watcher) WatcherMain(catchupChan chan bool)

The main function to do a watcher's job. It must be run as a goroutine

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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