2023-07-08 19:01:26 +02:00
|
|
|
package jsonrpc
|
2020-10-18 22:44:28 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2023-10-22 01:17:18 +02:00
|
|
|
"github.com/ledgerwatch/erigon-lib/common/hexutil"
|
2022-08-30 05:49:05 +03:00
|
|
|
|
2023-01-27 11:39:34 +07:00
|
|
|
"github.com/ledgerwatch/erigon-lib/common"
|
2023-01-13 18:12:18 +00:00
|
|
|
|
2022-11-08 09:35:00 +08:00
|
|
|
"github.com/ledgerwatch/erigon/eth/filters"
|
2021-12-16 23:08:27 +01:00
|
|
|
|
2021-07-29 18:53:13 +07:00
|
|
|
"github.com/ledgerwatch/erigon-lib/kv"
|
2023-01-13 18:12:18 +00:00
|
|
|
|
2021-05-21 01:25:53 +07:00
|
|
|
"github.com/ledgerwatch/erigon/core/types"
|
2021-12-01 01:42:12 +03:00
|
|
|
"github.com/ledgerwatch/erigon/p2p"
|
2021-05-21 01:25:53 +07:00
|
|
|
"github.com/ledgerwatch/erigon/rpc"
|
2022-06-10 16:18:43 +01:00
|
|
|
"github.com/ledgerwatch/erigon/turbo/rpchelper"
|
2020-10-18 22:44:28 +03:00
|
|
|
)
|
|
|
|
|
2021-05-26 13:35:39 +03:00
|
|
|
// ErigonAPI Erigon specific routines
|
|
|
|
type ErigonAPI interface {
|
|
|
|
// System related (see ./erigon_system.go)
|
2020-10-26 00:34:00 +03:00
|
|
|
Forks(ctx context.Context) (Forks, error)
|
2022-09-21 20:30:01 +08:00
|
|
|
BlockNumber(ctx context.Context, rpcBlockNumPtr *rpc.BlockNumber) (hexutil.Uint64, error)
|
2020-10-18 22:44:28 +03:00
|
|
|
|
2021-05-26 13:35:39 +03:00
|
|
|
// Blocks related (see ./erigon_blocks.go)
|
2020-10-20 17:16:28 -04:00
|
|
|
GetHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error)
|
2023-01-27 11:39:34 +07: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 11:39:34 +07:00
|
|
|
GetBalanceChangesInBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (map[common.Address]*hexutil.Big, error)
|
2020-10-18 22:44:28 +03:00
|
|
|
|
2021-05-26 13:35:39 +03:00
|
|
|
// Receipt related (see ./erigon_receipts.go)
|
2023-01-27 11:39:34 +07:00
|
|
|
GetLogsByHash(ctx context.Context, hash common.Hash) ([][]*types.Log, error)
|
2020-10-24 13:03:52 -04:00
|
|
|
//GetLogsByNumber(ctx context.Context, number rpc.BlockNumber) ([][]*types.Log, error)
|
2023-10-06 11:58:08 +01: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 11:39:34 +07:00
|
|
|
GetBlockReceiptsByBlockHash(ctx context.Context, cannonicalBlockHash common.Hash) ([]map[string]interface{}, error)
|
2020-10-20 17:16:28 -04:00
|
|
|
|
2021-12-01 01:42:12 +03:00
|
|
|
// NodeInfo returns a collection of metadata known about the host.
|
|
|
|
NodeInfo(ctx context.Context) ([]p2p.NodeInfo, error)
|
2020-10-18 22:44:28 +03:00
|
|
|
}
|
|
|
|
|
2021-05-26 13:35:39 +03:00
|
|
|
// ErigonImpl is implementation of the ErigonAPI interface
|
|
|
|
type ErigonImpl struct {
|
2021-01-03 02:28:22 +07:00
|
|
|
*BaseAPI
|
2021-12-01 01:42:12 +03:00
|
|
|
db kv.RoDB
|
2022-06-10 16:18:43 +01:00
|
|
|
ethBackend rpchelper.ApiBackend
|
2020-10-18 22:44:28 +03:00
|
|
|
}
|
|
|
|
|
2021-05-26 13:35:39 +03:00
|
|
|
// NewErigonAPI returns ErigonImpl instance
|
2022-06-10 16:18:43 +01:00
|
|
|
func NewErigonAPI(base *BaseAPI, db kv.RoDB, eth rpchelper.ApiBackend) *ErigonImpl {
|
2021-05-26 13:35:39 +03:00
|
|
|
return &ErigonImpl{
|
2021-12-01 01:42:12 +03:00
|
|
|
BaseAPI: base,
|
|
|
|
db: db,
|
|
|
|
ethBackend: eth,
|
2020-10-18 22:44:28 +03:00
|
|
|
}
|
|
|
|
}
|