mpseth

package
v0.0.0-...-3199497 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 13 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 ClientOp

type ClientOp int
const (
	ClientOPSubscribe ClientOp = iota
	ClientOPUnsubscribe
)

type FeedPacket

type FeedPacket struct {
	T    FeedType `json:"T"`
	Data any      `json:"Data"`
}

FeedPacket 服务器向客户端推送的数据类型

type FeedType

type FeedType int
const (
	FeedTypeChainConfig FeedType = iota
	FeedTypeTransactions
	FeedTypeBlockedTxHashes
	FeedTypeResponse
)

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(txs types.Transactions) 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 {
	Op ClientOp `json:"op"`
	// 请求id
	Id    int   `json:"id"`
	Topic Topic `json:"topic"`
}

type ResponsePacket

type ResponsePacket struct {
	// 响应的请求id
	Id      int    `json:"id"`
	Ok      bool   `json:"ok"`
	Message string `json:"message"`
}

type Server

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

func New

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

func (*Server) Start

func (a *Server) Start() error

func (*Server) Stop

func (a *Server) Stop() error

type Topic

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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