socket

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownEvent    = fmt.Errorf("unknown event")
	ErrSocketClosed    = fmt.Errorf("socket closed")
	ErrInvalidResponse = func(err error) error {
		return fmt.Errorf("invalid response: %v", err)
	}
	ErrUnknown = fmt.Errorf("unknown error")
)
View Source
var (
	SocketPath = path.Join(os.TempDir(), "relayer.sock")
)

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient() (*Client, error)

func (*Client) ClaimFee added in v1.1.0

func (c *Client) ClaimFee(chain string) (*ResClaimFee, error)

ClaimFee sends ClaimFee event to socket

func (*Client) Close

func (c *Client) Close() error

func (*Client) GetBlock

func (c *Client) GetBlock(chain string) ([]*ResGetBlock, error)

GetBlock sends GetBlock event to socket

func (*Client) GetFee added in v1.1.0

func (c *Client) GetFee(chain string, network string, isReponse bool) (*ResGetFee, error)

GetFee sends GetFee event to socket

func (*Client) GetMessageList

func (c *Client) GetMessageList(chain string, pagination *store.Pagination) (*ResMessageList, error)

GetMessageList sends GetMessageList event to socket

func (*Client) MessageRemove

func (c *Client) MessageRemove(chain string, sn uint64) (*ResMessageRemove, error)

MessageRemove sends MessageRemove event to socket

func (*Client) PruneDB

func (c *Client) PruneDB() (*ResPruneDB, error)

PruneDB sends PruneDB event to socket

func (*Client) RelayMessage

func (c *Client) RelayMessage(chain string, height, sn uint64) (*ResRelayMessage, error)

RelayMessage sends RelayMessage event to socket

func (*Client) RevertMessage

func (c *Client) RevertMessage(chain string, sn uint64) (*ResRevertMessage, error)

RevertMessage sends RevertMessage event to socket

func (*Client) SetFee added in v1.1.0

func (c *Client) SetFee(chain, network string, msgFee, resFee uint64) (*ResSetFee, error)

SetFee sends SetFee event to socket

type ErrResponse

type ErrResponse struct {
	Error string
}

type Event

type Event string
const (
	EventGetBlock       Event = "GetBlock"
	EventGetMessageList Event = "GetMessageList"
	EventRelayMessage   Event = "RelayMessage"
	EventMessageRemove  Event = "MessageRemove"
	EventPruneDB        Event = "PruneDB"
	EventRevertMessage  Event = "RevertMessage"
	EventError          Event = "Error"
	EventGetFee         Event = "GetFee"
	EventSetFee         Event = "SetFee"
	EventClaimFee       Event = "ClaimFee"
)

type Message

type Message struct {
	Event Event
	Data  []byte
}

type ReqClaimFee added in v1.1.0

type ReqClaimFee struct {
	Chain string
}

ReqClaimFee sends ClaimFee event to socket

type ReqGetBlock

type ReqGetBlock struct {
	Chain string
	All   bool
}

type ReqGetFee added in v1.1.0

type ReqGetFee struct {
	Chain    string
	Network  string
	Response bool
}

type ReqMessageList

type ReqMessageList struct {
	Chain      string
	Pagination *store.Pagination
}

type ReqMessageRemove

type ReqMessageRemove struct {
	Chain string
	Sn    uint64
}

type ReqPruneDB

type ReqPruneDB struct {
	Chain string
}

type ReqRelayMessage

type ReqRelayMessage struct {
	Chain  string
	Sn     uint64
	Height uint64
}

type ReqRevertMessage

type ReqRevertMessage struct {
	Chain string
	Sn    uint64
}

type ReqSetFee added in v1.1.0

type ReqSetFee struct {
	Chain   string
	Network string
	MsgFee  uint64
	ResFee  uint64
}

ReqSetFee sends SetFee event to socket

type ResClaimFee added in v1.1.0

type ResClaimFee struct {
	Status string
}

ResClaimFee sends ClaimFee event to socket

type ResGetBlock

type ResGetBlock struct {
	Chain  string
	Height uint64
}

type ResGetFee added in v1.1.0

type ResGetFee struct {
	Chain    string
	Fee      uint64
	Response bool
}

type ResMessageList

type ResMessageList struct {
	Messages []*types.RouteMessage
	Total    int
}

type ResMessageRemove

type ResMessageRemove struct {
	Sn     uint64
	Chain  string
	Dst    string
	Height uint64
	Event  string
}

type ResPruneDB

type ResPruneDB struct {
	Status string
}

type ResRelayMessage

type ResRelayMessage struct {
	*types.RouteMessage
}

type ResRevertMessage

type ResRevertMessage struct {
	Sn uint64
}

type ResSetFee added in v1.1.0

type ResSetFee struct {
	Status string
}

ResSetFee sends SetFee event to socket

type Server

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

func NewSocket

func NewSocket(rly *relayer.Relayer) (*Server, error)

func (*Server) Close

func (s *Server) Close() error

func (*Server) IsClosed

func (s *Server) IsClosed() bool

func (*Server) Listen

func (s *Server) Listen()

Listen to socket

Jump to

Keyboard shortcuts

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