Versions in this module Expand all Collapse all v0 v0.1.0 Nov 3, 2020 Changes in this version + const HANDSHAKE_ACK + const HANDSHAKE_FAIL + const HANDSHAKE_REQ + const JOIN_REQ + const PEERFIND_ACK + const PEERFIND_FAIL + const PEERFIND_REQ + const PREVOTE_FAIL + const PREVOTE_REQ + const PREVOTE_RES + const PUBLISH_ACK + const PUBLISH_REQ + const START_JOIN_ACK + const START_JOIN_FAIL + const START_JOIN_REQ + type Connection interface + GetDestAddress func() string + GetMessage func() string + GetSourceAddress func() string + SendRequest func(action string, req []byte, callback func(byte []byte)) + type ConnectionEntry struct + type DirectReplyChannel struct + func (c *DirectReplyChannel) GetDestAddress() string + func (c *DirectReplyChannel) GetSourceAddress() string + func (c *DirectReplyChannel) SendMessage(action string, b []byte) (int, error) + type HandshakeRequest struct + RemoteAddress string + func HandshakeRequestFromBytes(b []byte) *HandshakeRequest + func (h *HandshakeRequest) ToBytes() []byte + type HandshakeResponse struct + Node state.Node + func HandshakeResponseFromBytes(b []byte) *HandshakeResponse + func (h *HandshakeResponse) ToBytes() []byte + type LocalConnection struct + func (c *LocalConnection) GetDestAddress() string + func (c *LocalConnection) GetMessage() string + func (c *LocalConnection) GetSourceAddress() string + func (c *LocalConnection) SendRequest(action string, req []byte, callback func(response []byte)) + type ReplyChannel interface + GetDestAddress func() string + GetSourceAddress func() string + SendMessage func(action string, content []byte) (n int, err error) + type RequestHandler func(channel ReplyChannel, req []byte) + type Service struct + ConnectionLock sync.RWMutex + ConnectionManager map[string]ConnectionEntry + LocalNode *state.Node + Transport Transport + func NewService(transport Transport, nodeName string) *Service + func (s *Service) ConnectToRemoteNode(address string, callback func(node *state.Node)) + func (s *Service) GetConnectedPeers() ([]string, []state.Node) + func (s *Service) GetConnection(id string) ConnectionEntry + func (s *Service) GetLocalNode() state.Node + func (s *Service) GetNodeByAddress(address string) *state.Node + func (s *Service) GetSeedHosts() []string + func (s *Service) RegisterRequestHandler(action string, handler RequestHandler) + func (s *Service) SendRequest(node state.Node, action string, req []byte, callback func(response []byte)) + func (s *Service) SendRequestConn(conn Connection, action string, req []byte, callback func(response []byte)) + func (s *Service) SetConnection(key string, conn ConnectionEntry) + func (s *Service) Start(port int) + type Transport interface + GetHandler func(action string) RequestHandler + GetLocalAddress func() string + GetNodeId func() string + GetSeedHosts func() []string + OpenConnection func(address string, callback func(conn Connection)) + Register func(action string, handler RequestHandler) + Start func(port int)