2020-08-29 15:50:24 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2020-09-25 12:12:36 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/rpcdaemon/cli"
|
2020-08-29 15:50:24 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/common"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/common/hexutil"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
2020-09-25 12:12:36 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/rpc"
|
2020-08-29 15:50:24 +00:00
|
|
|
)
|
|
|
|
|
2020-09-25 12:12:36 +00:00
|
|
|
// TraceAPI RPC interface into tracing API
|
2020-08-29 15:50:24 +00:00
|
|
|
type TraceAPI interface {
|
2020-10-20 21:16:28 +00:00
|
|
|
// Ad-hoc (see ./trace_adhoc.go)
|
2020-09-26 06:41:34 +00:00
|
|
|
ReplayBlockTransactions(ctx context.Context, blockNr rpc.BlockNumber, traceTypes []string) ([]interface{}, error)
|
|
|
|
ReplayTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error)
|
2020-11-09 08:52:18 +00:00
|
|
|
Call(ctx context.Context, call TraceCallParam, types []string, blockNr *rpc.BlockNumberOrHash) ([]interface{}, error)
|
|
|
|
CallMany(ctx context.Context, calls []interface{}, blockNr *rpc.BlockNumberOrHash) ([]interface{}, error)
|
2020-09-26 06:41:34 +00:00
|
|
|
RawTransaction(ctx context.Context, txHash common.Hash, traceTypes []string) ([]interface{}, error)
|
2020-09-25 12:12:36 +00:00
|
|
|
|
2020-10-20 21:16:28 +00:00
|
|
|
// Filtering (see ./trace_filtering.go)
|
2020-09-25 12:12:36 +00:00
|
|
|
Transaction(ctx context.Context, txHash common.Hash) (ParityTraces, error)
|
|
|
|
Get(ctx context.Context, txHash common.Hash, txIndicies []hexutil.Uint64) (*ParityTrace, error)
|
|
|
|
Block(ctx context.Context, blockNr rpc.BlockNumber) (ParityTraces, error)
|
|
|
|
Filter(ctx context.Context, req TraceFilterRequest) (ParityTraces, error)
|
2020-08-29 15:50:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TraceAPIImpl is implementation of the TraceAPI interface based on remote Db access
|
|
|
|
type TraceAPIImpl struct {
|
2020-10-10 12:24:56 +00:00
|
|
|
dbReader ethdb.Database
|
2020-10-03 08:07:49 +00:00
|
|
|
maxTraces uint64
|
|
|
|
traceType string
|
2020-08-29 15:50:24 +00:00
|
|
|
}
|
|
|
|
|
2020-09-25 12:12:36 +00:00
|
|
|
// NewTraceAPI returns NewTraceAPI instance
|
2020-12-04 21:16:51 +00:00
|
|
|
func NewTraceAPI(dbReader ethdb.Database, cfg *cli.Flags) *TraceAPIImpl {
|
2020-08-29 15:50:24 +00:00
|
|
|
return &TraceAPIImpl{
|
2020-10-03 08:07:49 +00:00
|
|
|
dbReader: dbReader,
|
|
|
|
maxTraces: cfg.MaxTraces,
|
|
|
|
traceType: cfg.TraceType,
|
2020-08-29 15:50:24 +00:00
|
|
|
}
|
|
|
|
}
|