Documentation ¶
Index ¶
- Variables
- func CreateHistoryStateReader(tx kv.Tx, blockNumber uint64, txnIndex int, historyV3 bool, chainName string) (state.StateReader, error)
- func CreateStateReader(ctx context.Context, tx kv.Tx, blockNrOrHash rpc.BlockNumberOrHash, ...) (state.StateReader, error)
- func CreateStateReaderFromBlockNumber(ctx context.Context, tx kv.Tx, blockNumber uint64, latest bool, txnIndex int, ...) (state.StateReader, error)
- func GetBlockNumber(blockNrOrHash rpc.BlockNumberOrHash, tx kv.Tx, filters *Filters) (uint64, libcommon.Hash, bool, error)
- func GetCanonicalBlockNumber(blockNrOrHash rpc.BlockNumberOrHash, tx kv.Tx, filters *Filters) (uint64, libcommon.Hash, bool, error)
- func GetFinalizedBlockNumber(tx kv.Tx) (uint64, error)
- func GetLatestBlockNumber(tx kv.Tx) (uint64, error)
- func GetLatestExecutedBlockNumber(tx kv.Tx) (uint64, error)
- func GetSafeBlockNumber(tx kv.Tx) (uint64, error)
- func NewLatestStateReader(tx kv.Getter) state.StateReader
- func NewLatestStateWriter(tx kv.RwTx, blockNum uint64) state.StateWriter
- type ApiBackend
- type Filters
- func (ff *Filters) AddLogs(id LogsSubID, logs *types.Log)
- func (ff *Filters) AddPendingBlock(id HeadsSubID, block *types.Header)
- func (ff *Filters) AddPendingTxs(id PendingTxsSubID, txs []types.Transaction)
- func (ff *Filters) HandlePendingBlock(reply *txpool.OnPendingBlockReply)
- func (ff *Filters) HandlePendingLogs(reply *txpool.OnPendingLogsReply)
- func (ff *Filters) LastPendingBlock() *types.Block
- func (ff *Filters) OnNewEvent(event *remote.SubscribeReply)
- func (ff *Filters) OnNewLogs(reply *remote.SubscribeLogsReply)
- func (ff *Filters) OnNewTx(reply *txpool.OnAddReply)
- func (ff *Filters) ReadLogs(id LogsSubID) ([]*types.Log, bool)
- func (ff *Filters) ReadPendingBlocks(id HeadsSubID) ([]*types.Header, bool)
- func (ff *Filters) ReadPendingTxs(id PendingTxsSubID) ([][]types.Transaction, bool)
- func (ff *Filters) SubscribeLogs(size int, crit filters.FilterCriteria) (<-chan *types.Log, LogsSubID)
- func (ff *Filters) SubscribeNewHeads(size int) (<-chan *types.Header, HeadsSubID)
- func (ff *Filters) SubscribePendingBlock(size int) (<-chan *types.Block, PendingBlockSubID)
- func (ff *Filters) SubscribePendingLogs(size int) (<-chan types.Logs, PendingLogsSubID)
- func (ff *Filters) SubscribePendingTxs(size int) (<-chan []types.Transaction, PendingTxsSubID)
- func (ff *Filters) UnsubscribeHeads(id HeadsSubID) bool
- func (ff *Filters) UnsubscribeLogs(id LogsSubID) bool
- func (ff *Filters) UnsubscribePendingBlock(id PendingBlockSubID)
- func (ff *Filters) UnsubscribePendingLogs(id PendingLogsSubID)
- func (ff *Filters) UnsubscribePendingTxs(id PendingTxsSubID) bool
- type HeadsSubID
- type LogsFilter
- type LogsFilterAggregator
- type LogsSubID
- type PendingBlockSubID
- type PendingLogsSubID
- type PendingTxsSubID
- type Sub
- type SubscriptionID
- type SyncMap
- func (m *SyncMap[K, T]) Delete(k K) (t T, deleted bool)
- func (m *SyncMap[K, T]) Do(k K, fn func(T, bool) (T, bool)) (after T, ok bool)
- func (m *SyncMap[K, T]) DoAndStore(k K, fn func(t T, ok bool) T) (after T, ok bool)
- func (m *SyncMap[K, T]) Get(k K) (res T, ok bool)
- func (m *SyncMap[K, T]) Put(k K, v T) (T, bool)
- func (m *SyncMap[K, T]) Range(fn func(k K, v T) error) error
Constants ¶
This section is empty.
Variables ¶
var UnknownBlockError = &rpc.CustomError{
Code: -39001,
Message: "Unknown block",
}
Functions ¶
func CreateStateReader ¶
func GetBlockNumber ¶
func GetCanonicalBlockNumber ¶
func NewLatestStateReader ¶
func NewLatestStateReader(tx kv.Getter) state.StateReader
func NewLatestStateWriter ¶
func NewLatestStateWriter(tx kv.RwTx, blockNum uint64) state.StateWriter
Types ¶
type ApiBackend ¶
type ApiBackend interface { Etherbase(ctx context.Context) (libcommon.Address, error) NetVersion(ctx context.Context) (uint64, error) NetPeerCount(ctx context.Context) (uint64, error) ProtocolVersion(ctx context.Context) (uint64, error) ClientVersion(ctx context.Context) (string, error) Subscribe(ctx context.Context, cb func(*remote.SubscribeReply)) error SubscribeLogs(ctx context.Context, cb func(*remote.SubscribeLogsReply), requestor *atomic.Value) error BlockWithSenders(ctx context.Context, tx kv.Getter, hash libcommon.Hash, blockHeight uint64) (block *types.Block, senders []libcommon.Address, err error) NodeInfo(ctx context.Context, limit uint32) ([]p2p.NodeInfo, error) Peers(ctx context.Context) ([]*p2p.PeerInfo, error) AddPeer(ctx context.Context, url *remote.AddPeerRequest) (*remote.AddPeerReply, error) PendingBlock(ctx context.Context) (*types.Block, error) }
ApiBackend - interface which must be used by API layer implementation can work with local Ethereum object or with Remote (grpc-based) one this is reason why all methods are accepting context and returning error
type Filters ¶
type Filters struct {
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, ethBackend ApiBackend, txPool txpool.TxpoolClient, mining txpool.MiningClient, onNewSnapshot func(), logger log.Logger) *Filters
func (*Filters) AddPendingBlock ¶
func (ff *Filters) AddPendingBlock(id HeadsSubID, block *types.Header)
func (*Filters) AddPendingTxs ¶
func (ff *Filters) AddPendingTxs(id PendingTxsSubID, txs []types.Transaction)
func (*Filters) HandlePendingBlock ¶
func (ff *Filters) HandlePendingBlock(reply *txpool.OnPendingBlockReply)
func (*Filters) HandlePendingLogs ¶
func (ff *Filters) HandlePendingLogs(reply *txpool.OnPendingLogsReply)
func (*Filters) LastPendingBlock ¶
func (*Filters) OnNewEvent ¶
func (ff *Filters) OnNewEvent(event *remote.SubscribeReply)
OnNewEvent is called when there is a new Event from the remote
func (*Filters) OnNewLogs ¶
func (ff *Filters) OnNewLogs(reply *remote.SubscribeLogsReply)
OnNewLogs is called when there is a new log
func (*Filters) OnNewTx ¶
func (ff *Filters) OnNewTx(reply *txpool.OnAddReply)
func (*Filters) ReadPendingBlocks ¶
func (ff *Filters) ReadPendingBlocks(id HeadsSubID) ([]*types.Header, bool)
func (*Filters) ReadPendingTxs ¶
func (ff *Filters) ReadPendingTxs(id PendingTxsSubID) ([][]types.Transaction, bool)
func (*Filters) SubscribeLogs ¶
func (*Filters) SubscribeNewHeads ¶
func (ff *Filters) SubscribeNewHeads(size int) (<-chan *types.Header, HeadsSubID)
func (*Filters) SubscribePendingBlock ¶
func (ff *Filters) SubscribePendingBlock(size int) (<-chan *types.Block, PendingBlockSubID)
func (*Filters) SubscribePendingLogs ¶
func (ff *Filters) SubscribePendingLogs(size int) (<-chan types.Logs, PendingLogsSubID)
func (*Filters) SubscribePendingTxs ¶
func (ff *Filters) SubscribePendingTxs(size int) (<-chan []types.Transaction, PendingTxsSubID)
func (*Filters) UnsubscribeHeads ¶
func (ff *Filters) UnsubscribeHeads(id HeadsSubID) bool
func (*Filters) UnsubscribeLogs ¶
func (*Filters) UnsubscribePendingBlock ¶
func (ff *Filters) UnsubscribePendingBlock(id PendingBlockSubID)
func (*Filters) UnsubscribePendingLogs ¶
func (ff *Filters) UnsubscribePendingLogs(id PendingLogsSubID)
func (*Filters) UnsubscribePendingTxs ¶
func (ff *Filters) UnsubscribePendingTxs(id PendingTxsSubID) bool
type HeadsSubID ¶
type HeadsSubID SubscriptionID
type LogsFilter ¶
type LogsFilter struct {
// contains filtered or unexported fields
}
LogsFilter is used for both representing log filter for a specific subscriber (RPC daemon usually) and "aggregated" log filter representing a union of all subscribers. Therefore, the values in the mappings are counters (of type int) and they get deleted when counter goes back to 0 Also, addAddr and allTopic are int instead of bool because they are also counter, counting how many subscribers have this set on
func (*LogsFilter) Close ¶
func (l *LogsFilter) Close()
func (*LogsFilter) Send ¶
func (l *LogsFilter) Send(lg *types2.Log)
type LogsFilterAggregator ¶
type LogsFilterAggregator struct {
// contains filtered or unexported fields
}
func NewLogsFilterAggregator ¶
func NewLogsFilterAggregator() *LogsFilterAggregator
type LogsSubID ¶
type LogsSubID SubscriptionID
type PendingBlockSubID ¶
type PendingBlockSubID SubscriptionID
type PendingLogsSubID ¶
type PendingLogsSubID SubscriptionID
type PendingTxsSubID ¶
type PendingTxsSubID SubscriptionID
type Sub ¶
type Sub[T any] interface { Send(T) Close() }
a simple interface for subscriptions for rpc helper
type SubscriptionID ¶
type SubscriptionID string
type SyncMap ¶
type SyncMap[K comparable, T any] struct { // contains filtered or unexported fields }
func NewSyncMap ¶
func NewSyncMap[K comparable, T any]() *SyncMap[K, T]