Documentation
¶
Index ¶
- Variables
- func Logs2EthLogs(logs []*Log, round uint64, blockHash, txHash common.Hash, startIndex uint, ...) []*ethtypes.Log
- func New(ctxBackend context.Context, backendFactory BackendFactory, ...) (*Service, Backend, filters.SubscribeBackend, error)
- type Backend
- type BackendFactory
- type GetEthInfoBackend
- type Log
- type QueryableBackend
- type Result
- type Results
- type Service
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrGetLastRetainedRound = errors.New("get last retained round error in db")
View Source
var ErrNotHealthy = errors.New("not healthy")
ErrNotHealthy is the error returned if the gateway is unhealthy.
Functions ¶
func Logs2EthLogs ¶
func Logs2EthLogs(logs []*Log, round uint64, blockHash, txHash common.Hash, startIndex uint, txIndex uint32) []*ethtypes.Log
Logs2EthLogs converts logs in db to ethereum logs.
func New ¶
func New( ctxBackend context.Context, backendFactory BackendFactory, client client.RuntimeClient, runtimeID common.Namespace, storage storage.Storage, enablePruning bool, pruningStep uint64, indexingStart uint64, ) (*Service, Backend, filters.SubscribeBackend, error)
New creates a new indexer service.
Types ¶
type Backend ¶
type Backend interface {
QueryableBackend
GetEthInfoBackend
// Index indexes a block.
Index(
oasisBlock *block.Block,
txResults []*client.TransactionWithResults,
blockGasLimit uint64,
) error
// Prune removes indexed data for rounds equal to or earlier than the passed round.
Prune(round uint64) error
// Close performs backend-specific cleanup. The backend should not be used anymore after calling
// this method.
Close()
}
Backend is the indexer backend interface.
type BackendFactory ¶
type BackendFactory func(ctx context.Context, runtimeID common.Namespace, storage storage.Storage, sb filters.SubscribeBackend) (Backend, error)
BackendFactory is the indexer backend factory interface.
type GetEthInfoBackend ¶
type GetEthInfoBackend interface {
GetBlockByRound(round uint64) (*model.Block, error)
GetBlockByHash(blockHash ethcommon.Hash) (*model.Block, error)
GetBlockTransactionCountByRound(round uint64) (int, error)
GetBlockTransactionCountByHash(blockHash ethcommon.Hash) (int, error)
GetTransactionByBlockHashAndIndex(blockHash ethcommon.Hash, txIndex int) (*model.Transaction, error)
GetTransactionReceipt(txHash ethcommon.Hash) (map[string]interface{}, error)
BlockNumber() (uint64, error)
GetLogs(startRound, endRound uint64) ([]*model.Log, error)
}
GetEthInfoBackend is a backend for handling ethereum data.
type Log ¶
type Log struct {
Address common.Address `json:"address"`
Topics []common.Hash `json:"topics"`
Data []byte `json:"data"`
}
Log is the Oasis Log.
type QueryableBackend ¶
type QueryableBackend interface {
// QueryBlockRound queries block round by block hash.
QueryBlockRound(blockHash ethcommon.Hash) (uint64, error)
// QueryBlockHash queries block hash by round.
QueryBlockHash(round uint64) (ethcommon.Hash, error)
// QueryLastIndexedRound query continues indexed block round.
QueryLastIndexedRound() (uint64, error)
// QueryLastRetainedRound query the minimum round not pruned.
QueryLastRetainedRound() (uint64, error)
// QueryTransaction queries ethereum transaction by hash.
QueryTransaction(ethTxHash ethcommon.Hash) (*model.Transaction, error)
}
QueryableBackend is the read-only indexer backend interface.
type Result ¶
type Result struct {
// TxHash is the hash of the matched transaction.
TxHash hash.Hash
// TxIndex is the index of the matched transaction within the block.
TxIndex uint32
}
Result is a query result.
type Results ¶
Results are query results.
Map key is the round number and value is a list of transaction hashes that match the query.
type Service ¶
type Service struct {
service.BaseBackgroundService
// contains filtered or unexported fields
}
Service is an indexer service.
Click to show internal directories.
Click to hide internal directories.