blockscanner

package
v0.0.0-...-8acb6f8 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const MockErrorBlockHeight = 1024
View Source
const (
	ScanPosKey = "blockscanpos"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockScanStatus

type BlockScanStatus byte

BlockScanStatus

const (
	Processing BlockScanStatus = iota
	Failed
	Finished
	NotStarted
)

type BlockStatusItem

type BlockStatusItem struct {
	Height int64           `json:"height"`
	Status BlockScanStatus `json:"status"`
}

BlockStatusItem indicate the status of a block

type CommonBlockScanner

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

CommonBlockScanner is used to discover block height since both binance and thorchain use cosmos, so this part logic should be the same

func NewCommonBlockScanner

func NewCommonBlockScanner(cfg config.BlockScannerConfiguration, scannerStorage ScannerStorage, m *metrics.Metrics) (*CommonBlockScanner, error)

NewCommonBlockScanner create a new instance of CommonBlockScanner

func (*CommonBlockScanner) GetFromHttpWithRetry

func (b *CommonBlockScanner) GetFromHttpWithRetry(url string) ([]byte, error)

func (*CommonBlockScanner) GetHttpClient

func (b *CommonBlockScanner) GetHttpClient() *http.Client

GetHttpClient return the http client used internal to ourside world right now we need to use this for test

func (*CommonBlockScanner) GetMessages

func (b *CommonBlockScanner) GetMessages() <-chan int64

GetMessages return the channel

func (*CommonBlockScanner) Start

func (b *CommonBlockScanner) Start()

Start block scanner

func (*CommonBlockScanner) Stop

func (b *CommonBlockScanner) Stop() error

type LevelDBScannerStorage

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

LevelDBScannerStorage is a scanner storage backed by level db

func NewLevelDBScannerStorage

func NewLevelDBScannerStorage(db *leveldb.DB) (*LevelDBScannerStorage, error)

NewLevelDBScannerStorage create a new instance of LevelDBScannerStorage

func (*LevelDBScannerStorage) GetBlocksForRetry

func (ldbss *LevelDBScannerStorage) GetBlocksForRetry(failedOnly bool) ([]int64, error)

GetFailedBlocksForRetry

func (*LevelDBScannerStorage) GetScanPos

func (ldbss *LevelDBScannerStorage) GetScanPos() (int64, error)

GetScanPos get current Scan Pos

func (*LevelDBScannerStorage) RemoveBlockStatus

func (ldbss *LevelDBScannerStorage) RemoveBlockStatus(block int64) error

func (*LevelDBScannerStorage) SetBlockScanStatus

func (ldbss *LevelDBScannerStorage) SetBlockScanStatus(block int64, status BlockScanStatus) error

func (*LevelDBScannerStorage) SetScanPos

func (ldbss *LevelDBScannerStorage) SetScanPos(block int64) error

SetScanPos save current scan pos

type MockScannerStorage

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

MockScannerStorage is to mock scanner storage interface

func NewMockScannerStorage

func NewMockScannerStorage() *MockScannerStorage

NewMockScannerStorage create a new instance of MockScannerStorage

func (*MockScannerStorage) Close

func (mss *MockScannerStorage) Close() error

func (*MockScannerStorage) GetBlocksForRetry

func (mss *MockScannerStorage) GetBlocksForRetry(failedOnly bool) ([]int64, error)

func (*MockScannerStorage) GetScanPos

func (mss *MockScannerStorage) GetScanPos() (int64, error)

func (*MockScannerStorage) RemoveBlockStatus

func (mss *MockScannerStorage) RemoveBlockStatus(block int64) error

func (*MockScannerStorage) SetBlockScanStatus

func (mss *MockScannerStorage) SetBlockScanStatus(block int64, status BlockScanStatus) error

func (*MockScannerStorage) SetScanPos

func (mss *MockScannerStorage) SetScanPos(block int64) error

type ScannerStorage

type ScannerStorage interface {
	GetScanPos() (int64, error)
	SetScanPos(block int64) error

	SetBlockScanStatus(block int64, status BlockScanStatus) error
	RemoveBlockStatus(block int64) error

	GetBlocksForRetry(failedOnly bool) ([]int64, error)
	io.Closer
}

ScannerStorage define the method need to be used by scanner

Jump to

Keyboard shortcuts

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