2020-10-18 19:44:28 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-12-16 22:08:27 +00:00
|
|
|
|
2021-07-29 11:53:13 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/kv"
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/common"
|
|
|
|
"github.com/ledgerwatch/erigon/core/types"
|
2021-11-30 22:42:12 +00:00
|
|
|
"github.com/ledgerwatch/erigon/p2p"
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/rpc"
|
2022-06-10 15:18:43 +00:00
|
|
|
"github.com/ledgerwatch/erigon/turbo/rpchelper"
|
2020-10-18 19:44:28 +00:00
|
|
|
)
|
|
|
|
|
2021-05-26 10:35:39 +00:00
|
|
|
// ErigonAPI Erigon specific routines
|
|
|
|
type ErigonAPI interface {
|
|
|
|
// System related (see ./erigon_system.go)
|
2020-10-25 21:34:00 +00:00
|
|
|
Forks(ctx context.Context) (Forks, error)
|
2020-10-18 19:44:28 +00:00
|
|
|
|
2021-05-26 10:35:39 +00:00
|
|
|
// Blocks related (see ./erigon_blocks.go)
|
2020-10-20 21:16:28 +00:00
|
|
|
GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)
|
2020-10-18 19:44:28 +00:00
|
|
|
GetHeaderByHash(_ context.Context, hash common.Hash) (*types.Header, error)
|
2022-02-23 13:52:19 +00:00
|
|
|
GetBlockByTimestamp(ctx context.Context, timeStamp rpc.Timestamp, fullTx bool) (map[string]interface{}, error)
|
2020-10-18 19:44:28 +00:00
|
|
|
|
2021-05-26 10:35:39 +00:00
|
|
|
// Receipt related (see ./erigon_receipts.go)
|
2020-10-18 19:44:28 +00:00
|
|
|
GetLogsByHash(ctx context.Context, hash common.Hash) ([][]*types.Log, error)
|
2020-10-24 17:03:52 +00:00
|
|
|
//GetLogsByNumber(ctx context.Context, number rpc.BlockNumber) ([][]*types.Log, error)
|
2020-10-20 21:16:28 +00:00
|
|
|
|
2021-12-16 22:08:27 +00:00
|
|
|
// WatchTheBurn / reward related (see ./erigon_issuance.go)
|
|
|
|
WatchTheBurn(ctx context.Context, blockNr rpc.BlockNumber) (Issuance, error)
|
2021-11-30 22:42:12 +00:00
|
|
|
|
2022-01-27 10:49:03 +00:00
|
|
|
// CumulativeChainTraffic / related to chain traffic (see ./erigon_cumulative_index.go)
|
|
|
|
CumulativeChainTraffic(ctx context.Context, blockNr rpc.BlockNumber) (ChainTraffic, error)
|
|
|
|
|
2021-11-30 22:42:12 +00:00
|
|
|
// NodeInfo returns a collection of metadata known about the host.
|
|
|
|
NodeInfo(ctx context.Context) ([]p2p.NodeInfo, error)
|
2020-10-18 19:44:28 +00:00
|
|
|
}
|
|
|
|
|
2021-05-26 10:35:39 +00:00
|
|
|
// ErigonImpl is implementation of the ErigonAPI interface
|
|
|
|
type ErigonImpl struct {
|
2021-01-02 19:28:22 +00:00
|
|
|
*BaseAPI
|
2021-11-30 22:42:12 +00:00
|
|
|
db kv.RoDB
|
2022-06-10 15:18:43 +00:00
|
|
|
ethBackend rpchelper.ApiBackend
|
2020-10-18 19:44:28 +00:00
|
|
|
}
|
|
|
|
|
2021-05-26 10:35:39 +00:00
|
|
|
// NewErigonAPI returns ErigonImpl instance
|
2022-06-10 15:18:43 +00:00
|
|
|
func NewErigonAPI(base *BaseAPI, db kv.RoDB, eth rpchelper.ApiBackend) *ErigonImpl {
|
2021-05-26 10:35:39 +00:00
|
|
|
return &ErigonImpl{
|
2021-11-30 22:42:12 +00:00
|
|
|
BaseAPI: base,
|
|
|
|
db: db,
|
|
|
|
ethBackend: eth,
|
2020-10-18 19:44:28 +00:00
|
|
|
}
|
|
|
|
}
|