sse

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package sse is the SSE Client for MEV-Share

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Data  *MatchMakerEvent // Will be nil if an error occurred during poll
	Error error
}

Event represents a matchmaker event sent from sse subscription

type EventHistory

type EventHistory struct {
	// Block number of event's block
	Block uint64 `json:"block,omitempty"`
	// The timestamp when the event was emitted
	Timestamp uint64 `json:"timestamp,omitempty"`
	// Mev-share tx hint.
	Hint MatchMakerEvent `json:"hint,omitempty"`
}

Single historical mev-share transaction

type EventHistoryInfo

type EventHistoryInfo struct {
	Count        uint64 `json:"count"`
	MinBlock     uint64 `json:"minBlock"`
	MaxBlock     uint64 `json:"maxBlock"`
	MinTimestamp uint64 `json:"minTimestamp"`
	MaxLimit     uint64 `json:"maxLimit"`
}

Info on mev-share historical data

type EventHistoryParams

type EventHistoryParams struct {
	BlockStart     uint64 `json:"blockStart,omitempty"`
	BlockEnd       uint64 `json:"blockEnd:,omitempty"`
	TimestampStart uint64 `json:"timestampStart:,omitempty"`
	TimestampEnd   uint64 `json:"timestampEnd:,omitempty"`
	OffSet         uint64 `json:"offset:,omitempty"`
}

For querying historical mev-share transactions

type InternalClient

type InternalClient struct {
	BaseURL string // BaseURL is the base URL for the matchmaker
}

InternalClient is a client for the matchmaker

func (*InternalClient) EventHistoryInfo

func (c *InternalClient) EventHistoryInfo() (*EventHistoryInfo, error)

Gets info about historical mev-share data

func (*InternalClient) GetEventHistory

func (c *InternalClient) GetEventHistory(params EventHistoryParams) ([]EventHistory, error)

Gets historical mev-share data

func (*InternalClient) Subscribe

func (c *InternalClient) Subscribe(eventChan chan<- Event) (SSESubscription, error)

Subscribe to matchmaker events and returns a type that can be used to control the subscription

type MatchMakerEvent

type MatchMakerEvent struct {
	Hash        common.Hash          `json:"hash"`
	Logs        []types.Log          `json:"logs,omitempty"`
	Txs         []PendingTransaction `json:"txs,omitempty"`
	MevGasPrice *hexutil.Big         `json:"mevGasPrice,omitempty"`
	GasUsed     *hexutil.Big         `json:"gasUsed,omitempty"`
}

MatchMakerEvent represents the pending transaction hints sent by matchmaker

type PendingTransaction

type PendingTransaction struct {
	To               common.Address `json:"to"`
	FunctionSelector [4]byte        `json:"functionSelector,omitempty"`
	CallData         []byte         `json:"callData,omitempty"` // Could be replaces with geth.hexutil type
	MevGasPrice      *hexutil.Big   `json:"mevGasPrice,omitempty"`
	GasUsed          *hexutil.Big   `json:"gasUsed,omitempty"`
}

PendingTransaction represents the hits revealed by the matchmaker about the transaction / bundle

func (*PendingTransaction) UnmarshalJSON

func (t *PendingTransaction) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON data into a PendingTransaction

type SSEClient added in v0.3.0

type SSEClient interface {
	// Subscribe to events and returns a subscription
	Subscribe(eventChan chan<- Event) (SSESubscription, error)
	// MEV-Share event history
	EventHistoryInfo() (*EventHistoryInfo, error)
	// MEV-Share event history Params
	GetEventHistory(params EventHistoryParams) ([]EventHistory, error)
}

SSEClient is the SSE Client abstraction

func New

func New(baseURL string) SSEClient

New creates a new InternalClient for the matchmaker with the given base URL

type SSESubscription added in v0.2.0

type SSESubscription interface {
	// To stop the subscription
	Stop()
}

type Subscription

type Subscription struct {
	// contains filtered or unexported fields
}

Subscription represents a subscription to matchmaker events

func (*Subscription) Stop

func (s *Subscription) Stop()

Stop stops the subscription to matchmaker events

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL