mps

package
v0.0.0-...-b7d12aa Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConnClosed = errors.New("ws conn closed")

Functions

This section is empty.

Types

type ClientOpt

type ClientOpt int
const (
	ClientOptSubscribe ClientOpt = iota
	ClientOptUnsubscribe
)

type FeedPacket

type FeedPacket struct {
	Type FeedType `json:"type"`
	Data []byte   `json:"data"`
}

FeedPacket is the packet sent to mps client

type FeedType

type FeedType int
const (
	FeedTypeChainConfig FeedType = iota
	FeedTypeTransactions
	FeedTypeBlockedTxHashes
	FeedTypeResponse // response to client subscription requests
)

type MPS

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

MPS (Message Pushing Service) is designed to be used as a service embedded into go-ethereum.

func New

func New(pool txSub, bc blockchain, logger log.Logger) *MPS

func (*MPS) Start

func (s *MPS) Start() error

func (*MPS) Stop

func (s *MPS) Stop() error

type Remote

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

Remote represents one conn instance

func NewRemote

func NewRemote(c *websocket.Conn, logger log.Logger) *Remote

func (*Remote) FeedBlockedTxHash

func (r *Remote) FeedBlockedTxHash(hashes []common.Hash) error

FeedBlockedTxHash relay new blocked tx hash to clients

func (*Remote) FeedChainConfig

func (r *Remote) FeedChainConfig(config *params.ChainConfig) error

func (*Remote) FeedNewTx

func (r *Remote) FeedNewTx(txsWithSender TxsWithSender) error

FeedNewTx relay new tx event to clients

func (*Remote) FeedResponse

func (r *Remote) FeedResponse(id int, ok bool, msg string) error

FeedResponse respond to client requests

func (*Remote) RecvLoop

func (r *Remote) RecvLoop() error

func (*Remote) Serve

func (r *Remote) Serve(cfg *params.ChainConfig) error

Serve blocked until conn closed

func (*Remote) Stop

func (r *Remote) Stop()

type RequestPacket

type RequestPacket struct {
	Id    int       `json:"id"`
	Op    ClientOpt `json:"opt"`
	Topic Topic     `json:"topic"`
}

type ResponsePacket

type ResponsePacket struct {
	// quest id
	Id      int    `json:"id"`
	Ok      bool   `json:"ok"`
	Message string `json:"message"`
}

type Topic

type Topic string
const (
	TopicNewTx           Topic = "newTx"
	TopicBlockedTxHashes       = "blockedTxHashes"
)

type TxsWithSender

type TxsWithSender struct {
	Txs     types.Transactions `json:"txs"`
	Senders []*common.Address  `json:"senders"`
}

TxsWithSender is a wrapper of transactions and their senders, used to send txs packet to mps client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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