plugeth-utils/core/interface.go

135 lines
4.5 KiB
Go
Raw Normal View History

2021-08-31 20:24:20 +00:00
package core
import (
"context"
"math/big"
"time"
"github.com/holiman/uint256"
2021-08-31 20:24:20 +00:00
)
type Backend interface {
// General Ethereum API
Downloader() Downloader
SuggestGasTipCap(ctx context.Context) (*big.Int, error)
// ChainDb() Database
// AccountManager() *accounts.Manager
ExtRPCEnabled() bool
RPCGasCap() uint64 // global gas cap for eth_call over rpc: DoS protection
RPCTxFeeCap() float64 // global tx fee cap for all transaction related APIs
UnprotectedAllowed() bool // allows only for EIP155 transactions.
// Blockchain API
SetHead(number uint64)
HeaderByNumber(ctx context.Context, number int64) ([]byte, error) // RLP encoded header
HeaderByHash(ctx context.Context, hash Hash) ([]byte, error)
// HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Header, error)
CurrentHeader() []byte // RLP encoded header
CurrentBlock() []byte // RLP encoded block
2021-08-31 20:24:20 +00:00
BlockByNumber(ctx context.Context, number int64) ([]byte, error) // RLP encoded block
BlockByHash(ctx context.Context, hash Hash) ([]byte, error) // RLP encoded block
2021-08-31 20:24:20 +00:00
// BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Block, error)
// StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error)
// StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error)
GetReceipts(ctx context.Context, hash Hash) ([]byte, error) // JSON encoded receipt (YES, JSON)
GetTd(ctx context.Context, hash Hash) *big.Int
SubscribeChainEvent(ch chan<- ChainEvent) Subscription
SubscribeChainHeadEvent(ch chan<- ChainHeadEvent) Subscription
SubscribeChainSideEvent(ch chan<- ChainSideEvent) Subscription
// Transaction pool API
SendTx(ctx context.Context, signedTx []byte) error // RLP Encoded Transaction
2021-08-31 20:24:20 +00:00
GetTransaction(ctx context.Context, txHash Hash) ([]byte, Hash, uint64, uint64, error) // RLP Encoded transaction
GetPoolTransactions() ([][]byte, error) // []RLP ecnoded transactions
GetPoolTransaction(txHash Hash) []byte // RLP encoded transaction
2021-08-31 20:24:20 +00:00
GetPoolNonce(ctx context.Context, addr Address) (uint64, error)
Stats() (pending int, queued int)
TxPoolContent() (map[Address][][]byte, map[Address][][]byte) // RLP encoded transactions
SubscribeNewTxsEvent(chan<- NewTxsEvent) Subscription
// Filter API
BloomStatus() (uint64, uint64)
GetLogs(ctx context.Context, blockHash Hash) ([][]byte, error) // []RLP encoded logs
SubscribeLogsEvent(ch chan<- [][]byte) Subscription // []RLP encoded logs
SubscribePendingLogsEvent(ch chan<- [][]byte) Subscription // RLP Encoded logs
SubscribeRemovedLogsEvent(ch chan<- []byte) Subscription // RLP encoded logs
2021-08-31 20:24:20 +00:00
// ChainConfig() *params.ChainConfig
// Engine() consensus.Engine
}
type OpCode byte
type TracerResult interface {
CaptureStart(from Address, to Address, create bool, input []byte, gas uint64, value *big.Int)
CaptureState(pc uint64, op OpCode, gas, cost uint64, scope ScopeContext, rData []byte, depth int, err error)
CaptureFault(pc uint64, op OpCode, gas, cost uint64, scope ScopeContext, depth int, err error)
CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error)
2021-09-03 16:34:04 +00:00
Result() interface{}
2021-08-31 20:24:20 +00:00
}
type ScopeContext interface {
Memory() Memory
Stack() Stack
2021-08-31 20:24:20 +00:00
Contract() Contract
}
type Memory interface {
GetCopy(int64, int64) []byte
Len() int
2021-08-31 20:24:20 +00:00
}
type Stack interface {
Back(n int) *uint256.Int
Len() int
2021-08-31 20:24:20 +00:00
}
type Contract interface {
AsDelegate() Contract
GetOp(n uint64) OpCode
GetByte(n uint64) byte
Caller() Address
Address() Address
Value() *big.Int
2021-08-31 20:24:20 +00:00
}
type Downloader interface {
Progress() Progress
2021-08-31 20:24:20 +00:00
}
type Progress interface {
StartingBlock() uint64
CurrentBlock() uint64
HighestBlock() uint64
PulledStates() uint64
KnownStates() uint64
2021-08-31 20:24:20 +00:00
}
type Node interface {
Server() Server
DataDir() string
InstanceDir() string
IPCEndpoint() string
HTTPEndpoint() string
WSEndpoint() string
ResolvePath(x string) string
2021-08-31 20:24:20 +00:00
}
type Server interface {
PeerCount() int
2021-08-31 20:24:20 +00:00
}
type Logger interface {
Trace(string, ...interface{})
Debug(string, ...interface{})
Info(string, ...interface{})
Warn(string, ...interface{})
Crit(string, ...interface{})
Error(string, ...interface{})
2021-08-31 20:24:20 +00:00
}
2021-08-31 20:40:39 +00:00
type PluginLoader interface {
Lookup(name string, validate func(interface{}) bool) []interface{}
2021-08-31 20:40:39 +00:00
}