watcher

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

type RpcClient

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

func NewRpcClient

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

func (*RpcClient) GetBlockByHeight

func (client *RpcClient) GetBlockByHeight(height int64, retry bool) *types.BCHBlock

func (*RpcClient) GetBlockHash

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

**for tool

func (*RpcClient) GetBlockInfo

func (client *RpcClient) GetBlockInfo(hash string) (*types.BlockInfo, error)

func (*RpcClient) GetCCEpochs added in v0.4.0

func (client *RpcClient) GetCCEpochs(start, end uint64) []*cctypes.CCEpoch

func (*RpcClient) GetEpochs

func (client *RpcClient) GetEpochs(start, end uint64) []*stakingtypes.Epoch

func (*RpcClient) GetLatestHeight

func (client *RpcClient) GetLatestHeight(retry bool) (height int64)

func (*RpcClient) GetTxInfo

func (client *RpcClient) GetTxInfo(hash string, blockhash string) (*types.TxInfo, error)

type Watcher

type Watcher struct {
	EpochChan chan *stakingtypes.Epoch

	CCEpochChan chan *cctypes.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) *Watcher

func (*Watcher) CheckSanity

func (watcher *Watcher) CheckSanity(disableBchClient, skipCheck bool)

func (*Watcher) ClearOldData

func (watcher *Watcher) ClearOldData()

func (*Watcher) GetCurrEpoch

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

func (*Watcher) GetCurrMainnetBlockTimestamp added in v0.4.5

func (watcher *Watcher) GetCurrMainnetBlockTimestamp() int64

func (*Watcher) GetEpochList added in v0.4.5

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

func (*Watcher) Run

func (watcher *Watcher) Run()

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

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) WaitCatchup added in v0.4.6

func (watcher *Watcher) WaitCatchup()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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