socket

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 11 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 = getEnvOrFallback("SOCKET_PATH", path.Join(os.TempDir(), "relayer.sock"))
)

Functions

This section is empty.

Types

type ChainProviderError added in v1.6.0

type ChainProviderError struct {
	Message string
}

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) GetLatestHeight added in v1.9.0

func (c *Client) GetLatestHeight(chain string) (*ResChainHeight, error)

func (*Client) GetMessageList

func (c *Client) GetMessageList(chain string, limit uint) (*ResMessageList, error)

GetMessageList sends GetMessageList event to socket

func (*Client) MessageRemove

func (c *Client) MessageRemove(chain string, sn *big.Int) (*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) QueryBlockRange added in v1.9.0

func (c *Client) QueryBlockRange(chain string, fromHeight, toHeight uint64) (*ResRangeBlockQuery, error)

func (*Client) RelayMessage

func (c *Client) RelayMessage(chain string, height uint64, txHash string) ([]*types.Message, 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 *big.Int) (*ResSetFee, error)

SetFee sends SetFee event to socket

type ErrResponse

type ErrResponse struct {
	Error string `json:"error"`
}

type Event

type Event string
const (
	EventGetBlock          Event = "GetBlock"
	EventGetMessageList    Event = "GetMessageList"
	EventRelayMessage      Event = "RelayMessage"
	EventRelayRangeMessage Event = "RelayRangeMessage"
	EventMessageRemove     Event = "MessageRemove"
	EventPruneDB           Event = "PruneDB"
	EventRevertMessage     Event = "RevertMessage"
	EventError             Event = "Error"
	EventGetFee            Event = "GetFee"
	EventSetFee            Event = "SetFee"
	EventClaimFee          Event = "ClaimFee"
	EventGetLatestHeight   Event = "GetLatestHeight"
	EventGetBlockRange     Event = "GetBlockRange"
	EventGetConfig         Event = "GetConfig"
	EventListChainInfo     Event = "ListChainInfo"
	EventGetBalance        Event = "GetChainBalance"
	EventRelayerInfo       Event = "RelayerInfo"
	EventMessageReceived   Event = "MessageReceived"
	EventGetBlockEvents    Event = "GetBlockEvents"
)

type Pagination added in v1.9.0

type Pagination struct {
	Page  uint
	Limit uint
}

type ReqChainHeight added in v1.9.0

type ReqChainHeight struct {
	Chain string `json:"chain"`
}

type ReqClaimFee added in v1.1.0

type ReqClaimFee struct {
	Chain string `json:"chain"`
}

ReqClaimFee sends ClaimFee event to socket

type ReqGetBalance added in v1.9.0

type ReqGetBalance struct {
	Chain   string `json:"chain"`
	Address string `json:"address"`
}

type ReqGetBlock

type ReqGetBlock struct {
	Chain string `json:"chain"`
}

type ReqGetBlockEvents added in v1.9.0

type ReqGetBlockEvents struct {
	Height uint64 `json:"height,omitempty"`
	TxHash string `json:"txHash,omitempty"`
}

type ReqGetFee added in v1.1.0

type ReqGetFee struct {
	Chain    string `json:"chain"`
	Network  string `json:"network"`
	Response bool   `json:"response"`
}

type ReqListChain added in v1.9.0

type ReqListChain struct {
	Chains []string `json:"chains,omitempty"`
}

type ReqMessageList

type ReqMessageList struct {
	Chain string `json:"chain"`
	Limit uint   `json:"pagination"`
}

type ReqMessageReceived added in v1.9.0

type ReqMessageReceived struct {
	Chain string `json:"chain"`
	Sn    uint64 `json:"sn"`
}

type ReqMessageRemove

type ReqMessageRemove struct {
	Chain string   `json:"chain"`
	Sn    *big.Int `json:"sn"`
}

type ReqProcessedBlock added in v1.9.0

type ReqProcessedBlock struct {
	Chain string `json:"chain"`
}

type ReqPruneDB

type ReqPruneDB struct {
	ID    string `json:"id"`
	Chain string `json:"chain"`
}

type ReqRangeBlockQuery added in v1.9.0

type ReqRangeBlockQuery struct {
	Chain      string `json:"chain"`
	FromHeight uint64 `json:"from_height"`
	ToHeight   uint64 `json:"to_height"`
}

type ReqRelayInfo added in v1.9.0

type ReqRelayInfo struct{}

type ReqRelayMessage

type ReqRelayMessage struct {
	Chain  string `json:"chain"`
	Height uint64 `json:"height"`
	TxHash string `json:"txHash"`
}

type ReqRevertMessage

type ReqRevertMessage struct {
	Chain string `json:"chain"`
	Sn    uint64 `json:"sn"`
}

type ReqSetFee added in v1.1.0

type ReqSetFee struct {
	Chain   string   `json:"chain"`
	Network string   `json:"network"`
	MsgFee  *big.Int `json:"msg_fee"`
	ResFee  *big.Int `json:"res_fee"`
}

ReqSetFee sends SetFee event to socket

type Request added in v1.9.0

type Request struct {
	ID    string `json:"id"`
	Event Event  `json:"event"`
	Data  any    `json:"data"`
}

type ResChainHeight added in v1.9.0

type ResChainHeight struct {
	Chain  string `json:"chain"`
	Height uint64 `json:"height"`
}

type ResChainInfo added in v1.9.0

type ResChainInfo struct {
	Name           string            `json:"name"`
	NID            string            `json:"nid"`
	Address        string            `json:"address"`
	Type           string            `json:"type"`
	Contracts      map[string]string `json:"contracts"`
	LatestHeight   uint64            `json:"latestHeight"`
	LastCheckPoint uint64            `json:"lastCheckPoint"`
}

type ResClaimFee added in v1.1.0

type ResClaimFee struct {
	Status string `json:"status"`
}

ResClaimFee sends ClaimFee event to socket

type ResGetBalance added in v1.9.0

type ResGetBalance struct {
	Chain   string      `json:"chain"`
	Address string      `json:"address"`
	Balance *types.Coin `json:"balance"`
	Value   string      `json:"value"`
}

type ResGetBlock

type ResGetBlock struct {
	Chain            string `json:"chain"`
	CheckPointHeight uint64 `json:"checkPointHeight"`
	LatestHeight     uint64 `json:"latestHeight"`
}

type ResGetBlockEvents added in v1.9.0

type ResGetBlockEvents struct {
	Event     string `json:"event"`
	Height    uint64 `json:"height"`
	Executed  bool   `json:"executed"`
	TxHash    string `json:"txHash"`
	ChainInfo struct {
		NID       string                  `json:"nid"`
		Name      string                  `json:"name"`
		Type      string                  `json:"type"`
		Contracts types.ContractConfigMap `json:"contracts"`
	} `json:"chainInfo"`
}

type ResGetFee added in v1.1.0

type ResGetFee struct {
	Chain    string `json:"chain"`
	Fee      uint64 `json:"fee"`
	Response bool   `json:"response"`
}

type ResMessageList

type ResMessageList struct {
	Message []*types.RouteMessage `json:"message"`
	Total   int                   `json:"total"`
}

type ResMessageReceived added in v1.9.0

type ResMessageReceived struct {
	Chain    string `json:"chain"`
	Sn       uint64 `json:"sn"`
	Received bool   `json:"received"`
}

type ResMessageRemove

type ResMessageRemove struct {
	Sn     *big.Int `json:"sn"`
	Chain  string   `json:"chain"`
	Dst    string   `json:"dst"`
	Height uint64   `json:"height"`
	Event  string   `json:"event"`
}

type ResPruneDB

type ResPruneDB struct {
	Status string `json:"status"`
}

type ResRangeBlockQuery added in v1.9.0

type ResRangeBlockQuery struct {
	Chain string           `json:"chain"`
	Msgs  []*types.Message `json:"messages"`
}

type ResRelayInfo added in v1.9.0

type ResRelayInfo struct {
	Version string `json:"version"`
	Uptime  int64  `json:"uptime"`
}

type ResRevertMessage

type ResRevertMessage struct {
	Sn uint64 `json:"sn"`
}

type ResSetFee added in v1.1.0

type ResSetFee struct {
	Status string `json:"status"`
}

ResSetFee sends SetFee event to socket

type Response added in v1.9.0

type Response struct {
	ID      string `json:"id"`
	Event   Event  `json:"event"`
	Success bool   `json:"success"`
	Data    any    `json:"data,omitempty"`
	Message string `json:"message,omitempty"`
}

func (*Response) SetData added in v1.9.0

func (r *Response) SetData(data any) *Response

func (*Response) SetError added in v1.9.0

func (r *Response) SetError(err error) *Response

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