Documentation ¶
Index ¶
- Constants
- type Block
- type BlockScanStatus
- type BlockScanner
- type BlockScannerFetcher
- type BlockScannerStorage
- type BlockStatusItem
- type DummyFetcher
- type LevelDBScannerStorage
- func (ldbss *LevelDBScannerStorage) Close() error
- func (ldbss *LevelDBScannerStorage) GetBlocksForRetry(failedOnly bool) ([]Block, error)
- func (ldbss *LevelDBScannerStorage) GetScanPos() (int64, error)
- func (ldbss *LevelDBScannerStorage) RemoveBlockStatus(block int64) error
- func (ldbss *LevelDBScannerStorage) SetBlockScanStatus(block Block, status BlockScanStatus) error
- func (ldbss *LevelDBScannerStorage) SetScanPos(block int64) error
- type MockScannerStorage
- func (mss *MockScannerStorage) Close() error
- func (mss *MockScannerStorage) GetBlocksForRetry(failedOnly bool) ([]Block, error)
- func (mss *MockScannerStorage) GetInternalDb() *leveldb.DB
- func (mss *MockScannerStorage) GetScanPos() (int64, error)
- func (mss *MockScannerStorage) RemoveBlockStatus(block int64) error
- func (mss *MockScannerStorage) SetBlockScanStatus(block Block, status BlockScanStatus) error
- func (mss *MockScannerStorage) SetScanPos(block int64) error
- type ScannerStorage
Constants ¶
const MockErrorBlockHeight = 1024
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 BlockScanner ¶
type BlockScanner struct {
// contains filtered or unexported fields
}
BlockScanner is used to discover block height
func NewBlockScanner ¶
func NewBlockScanner(cfg config.BifrostBlockScannerConfiguration, 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)
FetchLastHeight determines the height to start scanning:
- Use the config start height if set.
- If last consensus inbound height (lastblock) is available: a) Use local scanner storage height if available, up to the max lag from lastblock. b) Otherwise, use lastblock.
- Otherwise, use local scanner storage height if available.
- Otherwise, use the last height from the chain itself.
func (*BlockScanner) GetMessages ¶
func (b *BlockScanner) GetMessages() <-chan int64
GetMessages return the channel
func (*BlockScanner) IsHealthy ¶ added in v0.41.0
func (b *BlockScanner) IsHealthy() bool
IsHealthy return if the block scanner is healthy or not
func (*BlockScanner) PreviousHeight ¶ added in v1.125.0
func (b *BlockScanner) PreviousHeight() int64
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 { // FetchMemPool scan the mempool FetchMemPool(height int64) (types.TxIn, error) // FetchTxs scan block with the given height FetchTxs(fetchHeight, chainHeight int64) (types.TxIn, error) // GetHeight return current block height GetHeight() (int64, error) }
BlockScannerFetcher define the methods a block scanner need to implement
type BlockScannerStorage ¶
type BlockScannerStorage struct { *LevelDBScannerStorage // contains filtered or unexported fields }
BlockScannerStorage
func NewBlockScannerStorage ¶
func NewBlockScannerStorage(levelDbFolder string, opts config.LevelDBOptions) (*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 ¶
func (DummyFetcher) FetchMemPool ¶ added in v0.41.0
func (d DummyFetcher) FetchMemPool(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