2023-07-08 17:01:26 +00:00
|
|
|
package jsonrpc
|
2020-10-18 19:44:28 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2023-10-21 23:17:18 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/common/hexutil"
|
2022-08-30 02:49:05 +00:00
|
|
|
|
2023-01-27 04:39:34 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/common"
|
2023-01-13 18:12:18 +00:00
|
|
|
|
2022-11-08 01:35:00 +00:00
|
|
|
"github.com/ledgerwatch/erigon/eth/filters"
|
2021-12-16 22:08:27 +00:00
|
|
|
|
2021-07-29 11:53:13 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/kv"
|
2023-01-13 18:12:18 +00:00
|
|
|
|
2021-05-20 18:25:53 +00:00
|
|
|
"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)
|
2022-09-21 12:30:01 +00:00
|
|
|
BlockNumber(ctx context.Context, rpcBlockNumPtr *rpc.BlockNumber) (hexutil.Uint64, 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)
|
2023-01-27 04:39:34 +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)
|
2023-01-27 04:39:34 +00:00
|
|
|
GetBalanceChangesInBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (map[common.Address]*hexutil.Big, error)
|
2020-10-18 19:44:28 +00:00
|
|
|
|
2021-05-26 10:35:39 +00:00
|
|
|
// Receipt related (see ./erigon_receipts.go)
|
2023-01-27 04:39:34 +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)
|
2023-10-06 10:58:08 +00:00
|
|
|
GetLogs(ctx context.Context, crit filters.FilterCriteria) (types.ErigonLogs, error)
|
|
|
|
GetLatestLogs(ctx context.Context, crit filters.FilterCriteria, logOptions filters.LogFilterOptions) (types.ErigonLogs, error)
|
2022-12-13 20:41:51 +00:00
|
|
|
// Gets cannonical block receipt through hash. If the block is not cannonical returns error
|
2023-01-27 04:39:34 +00:00
|
|
|
GetBlockReceiptsByBlockHash(ctx context.Context, cannonicalBlockHash common.Hash) ([]map[string]interface{}, error)
|
2020-10-20 21:16:28 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|