blockscanner

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: MIT Imports: 21 Imported by: 5

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 Block

type Block struct {
	Height int64
	Txs    []string
}

type BlockScanStatus

type BlockScanStatus byte

BlockScanStatus

const (
	Processing BlockScanStatus = iota
	Failed
	Finished
	NotStarted
)

type BlockScanner

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

BlockScanner is used to discover block height

func NewBlockScanner

func NewBlockScanner(cfg config.BlockScannerConfiguration, scannerStorage ScannerStorage, m *metrics.Metrics, thorchainBridge *thorclient.ThorchainBridge, chainScanner BlockScannerFetcher) (*BlockScanner, error)

NewBlockScanner create a new instance of BlockScanner

func (*BlockScanner) FetchLastHeight

func (b *BlockScanner) FetchLastHeight() (int64, error)

func (*BlockScanner) GetMessages

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

GetMessages return the channel

func (*BlockScanner) Start

func (b *BlockScanner) Start(globalTxsQueue chan types.TxIn)

Start block scanner

func (*BlockScanner) Stop

func (b *BlockScanner) Stop()

type BlockScannerFetcher

type BlockScannerFetcher interface {
	FetchTxs(height int64) (types.TxIn, error)
	GetHeight() (int64, error)
}

type BlockScannerStorage

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

BlockScannerStorage

func NewBlockScannerStorage

func NewBlockScannerStorage(levelDbFolder string) (*BlockScannerStorage, error)

func (*BlockScannerStorage) GetInternalDb

func (s *BlockScannerStorage) GetInternalDb() *leveldb.DB

type BlockStatusItem

type BlockStatusItem struct {
	Block  Block           `json:"block"`
	Status BlockScanStatus `json:"status"`
}

BlockStatusItem indicate the status of a block

type DummyFetcher

type DummyFetcher struct {
	Tx  types.TxIn
	Err error
}

func NewDummyFetcher

func NewDummyFetcher(tx types.TxIn, err error) DummyFetcher

func (DummyFetcher) FetchTxs

func (d DummyFetcher) FetchTxs(height int64) (types.TxIn, error)

func (DummyFetcher) GetHeight

func (d DummyFetcher) GetHeight() (int64, 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) Close

func (ldbss *LevelDBScannerStorage) Close() error

func (*LevelDBScannerStorage) GetBlocksForRetry

func (ldbss *LevelDBScannerStorage) GetBlocksForRetry(failedOnly bool) ([]Block, 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 Block, 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) ([]Block, error)

func (*MockScannerStorage) GetInternalDb

func (mss *MockScannerStorage) GetInternalDb() *leveldb.DB

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 Block, 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 Block, status BlockScanStatus) error
	RemoveBlockStatus(block int64) error

	GetBlocksForRetry(failedOnly bool) ([]Block, error)
	GetInternalDb() *leveldb.DB
	io.Closer
}

ScannerStorage define the method need to be used by scanner

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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