Documentation ¶
Index ¶
- Constants
- Variables
- func NewProtocol(inC <-chan interface{}, quitC <-chan struct{}, ...) *p2p.Protocol
- func NewService(inC <-chan interface{}, quitC <-chan struct{}, ...) func(ctx *node.ServiceContext) (node.Service, error)
- type OrderbookAPI
- type OrderbookHandler
- type OrderbookHandshake
- type OrderbookMsg
- type OrderbookService
Constants ¶
View Source
const (
OrderbookName = "orderbook"
)
Variables ¶
View Source
var ( OrderbookProtocol = &protocols.Spec{ Name: OrderbookName, Version: 42, MaxMsgSize: 1024, Messages: []interface{}{ &OrderbookHandshake{}, &OrderbookMsg{}, }, } )
Functions ¶
func NewProtocol ¶
func NewProtocol(inC <-chan interface{}, quitC <-chan struct{}, orderbookEngine *orderbook.Engine) *p2p.Protocol
create the protocol with the protocols extension
func NewService ¶
func NewService(inC <-chan interface{}, quitC <-chan struct{}, orderbookEngine *orderbook.Engine) func(ctx *node.ServiceContext) (node.Service, error)
NewService: wrapper function for servicenode to start the service, both APIs and Protocols
Types ¶
type OrderbookAPI ¶
remember that API structs to be offered MUST be exported
func NewOrderbookAPI ¶
func NewOrderbookAPI(v int, orderbookEngine *orderbook.Engine) *OrderbookAPI
func (*OrderbookAPI) GetBestAskList ¶
func (api *OrderbookAPI) GetBestAskList(pairName string) []map[string]string
func (*OrderbookAPI) GetBestBidList ¶
func (api *OrderbookAPI) GetBestBidList(pairName string) []map[string]string
func (*OrderbookAPI) GetOrder ¶
func (api *OrderbookAPI) GetOrder(pairName, orderID string) map[string]string
func (*OrderbookAPI) Version ¶
func (api *OrderbookAPI) Version() (int, error)
Version : return version
type OrderbookHandler ¶
type OrderbookHandler struct { Engine *orderbook.Engine Peer *protocols.Peer InC <-chan interface{} QuitC <-chan struct{} }
the protocols abstraction enables use of an external handler function
type OrderbookHandshake ¶
type OrderbookMsg ¶
type OrderbookMsg struct { PairName string OrderID string Price string Quantity string Side string Timestamp uint64 TradeID string Type string }
func NewOrderbookMsg ¶
func NewOrderbookMsg(quote map[string]string) (*OrderbookMsg, error)
func (*OrderbookMsg) ToQuote ¶
func (msg *OrderbookMsg) ToQuote() map[string]string
type OrderbookService ¶
type OrderbookService struct { V int Engine *orderbook.Engine // contains filtered or unexported fields }
the service we want to offer on the node it must implement the node.Service interface
func (*OrderbookService) APIs ¶
func (service *OrderbookService) APIs() []rpc.API
APIs : api service specify API structs that carry the methods we want to use
func (*OrderbookService) Protocols ¶
func (service *OrderbookService) Protocols() []p2p.Protocol
these are needed to satisfy the node.Service interface in this example they do nothing
func (*OrderbookService) Stop ¶
func (service *OrderbookService) Stop() error
Click to show internal directories.
Click to hide internal directories.