Documentation ¶
Overview ¶
Package server provides the server implementation.
Index ¶
- Constants
- type BlockHeadersChannel
- type BlockSyncChannel
- type BlockSyncSubscriber
- type Channel
- type ConnectedClient
- type FilterChannel
- type MempoolTransactionsChannel
- type ProcessorNode
- type Server
- func (s *Server) GetChannel(client *centrifuge.Client, channelName string) Channel
- func (s *Server) Start(cfg *config.Config)
- func (s *Server) StartBlockHeadersListener() error
- func (s *Server) StartMempoolListener() error
- func (s *Server) StopBlockHeadersListener() error
- func (s *Server) StopMempoolListener() error
- type Subscriber
Constants ¶
const BlockHeaders = "block:headers"
BlockHeaders is the channel name for block headers.
const BlockSync = "block:sync:"
BlockSync is the channel name for block sync.
const Filter = "filter"
Filter is the verb for filtering.
const MempoolTransactions = "mempool:transactions"
MempoolTransactions is the channel name for mempool transactions.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockHeadersChannel ¶
type BlockHeadersChannel struct { Client *centrifuge.Client Node *centrifuge.Node }
BlockHeadersChannel is the channel for block headers.
func (*BlockHeadersChannel) ProcessPublish ¶
func (c *BlockHeadersChannel) ProcessPublish(_ centrifuge.PublishEvent) ([]byte, error)
ProcessPublish is called when a client publishes to this channel.
func (*BlockHeadersChannel) ProcessSubscribe ¶
func (c *BlockHeadersChannel) ProcessSubscribe(_ centrifuge.SubscribeEvent) ([]byte, error)
ProcessSubscribe is called when a client subscribes to this channel.
type BlockSyncChannel ¶
type BlockSyncChannel struct { Client *centrifuge.Client Processor chainstate.MonitorProcessor Node *centrifuge.Node }
BlockSyncChannel is the channel for block sync.
func (*BlockSyncChannel) ProcessPublish ¶
func (c *BlockSyncChannel) ProcessPublish(e centrifuge.PublishEvent) ([]byte, error)
ProcessPublish is called when a client publishes to this channel.
func (*BlockSyncChannel) ProcessSubscribe ¶
func (c *BlockSyncChannel) ProcessSubscribe(e centrifuge.SubscribeEvent) ([]byte, error)
ProcessSubscribe is called when a client subscribes to this channel.
type BlockSyncSubscriber ¶
type BlockSyncSubscriber struct { Channel string `json:"channel"` From string `json:"from"` To string `json:"to"` Transactions []node.Tx `json:"transactions"` Block *node.Block Synced bool `json:"synced"` Processor chainstate.MonitorProcessor Node *centrifuge.Node }
BlockSyncSubscriber is the subscriber for block sync.
func (*BlockSyncSubscriber) GetTransactions ¶
func (b *BlockSyncSubscriber) GetTransactions() ([]node.Tx, error)
GetTransactions returns the transactions.
func (*BlockSyncSubscriber) Publish ¶
func (b *BlockSyncSubscriber) Publish(data []byte) error
Publish publishes the block to the centrifuge node.
func (*BlockSyncSubscriber) Subscribe ¶
func (b *BlockSyncSubscriber) Subscribe() error
Subscribe subscribes to the block sync channel.
type Channel ¶
type Channel interface { ProcessPublish(e centrifuge.PublishEvent) ([]byte, error) ProcessSubscribe(e centrifuge.SubscribeEvent) ([]byte, error) }
Channel is an interface that must be implemented by all channels.
type ConnectedClient ¶
ConnectedClient is a client that is connected to the server.
type FilterChannel ¶
type FilterChannel struct { Client *centrifuge.Client Processor chainstate.MonitorProcessor Node *centrifuge.Node }
FilterChannel is the channel for filters.
func (*FilterChannel) ProcessPublish ¶
func (c *FilterChannel) ProcessPublish(e centrifuge.PublishEvent) ([]byte, error)
ProcessPublish is called when a client publishes to this channel.
func (*FilterChannel) ProcessSubscribe ¶
func (c *FilterChannel) ProcessSubscribe(e centrifuge.SubscribeEvent) ([]byte, error)
ProcessSubscribe is called when a client subscribes to this channel.
type MempoolTransactionsChannel ¶
type MempoolTransactionsChannel struct { Client *centrifuge.Client Node *centrifuge.Node }
MempoolTransactionsChannel is the channel for mempool transactions.
func (*MempoolTransactionsChannel) ProcessPublish ¶
func (c *MempoolTransactionsChannel) ProcessPublish(_ centrifuge.PublishEvent) ([]byte, error)
ProcessPublish is called when a client publishes to this channel.
func (*MempoolTransactionsChannel) ProcessSubscribe ¶
func (c *MempoolTransactionsChannel) ProcessSubscribe(_ centrifuge.SubscribeEvent) ([]byte, error)
ProcessSubscribe is called when a client subscribes to this channel.
type ProcessorNode ¶
type ProcessorNode struct { Processor chainstate.MonitorProcessor Node *centrifuge.Node }
ProcessorNode is the struct that wraps the centrifuge node and the processor.
type Server ¶
type Server struct { Node *centrifuge.Node Client *centrifuge.Client Processor chainstate.MonitorProcessor ClientMap map[string]*ConnectedClient MempoolClient *centrifugeClient.Client BlockHeadersClient *centrifugeClient.Client }
Server represents a server.
func (*Server) GetChannel ¶
func (s *Server) GetChannel(client *centrifuge.Client, channelName string) Channel
GetChannel returns the channel for the given channel name.
func (*Server) StartBlockHeadersListener ¶
StartBlockHeadersListener starts the block headers listener
func (*Server) StartMempoolListener ¶
StartMempoolListener starts the mempool listener
func (*Server) StopBlockHeadersListener ¶
StopBlockHeadersListener stops the block headers listener
func (*Server) StopMempoolListener ¶
StopMempoolListener stops the mempool listener