Documentation ¶
Index ¶
- Constants
- Variables
- func MarshallMessageOfInterest(messageTags []protocol.Tag) []byte
- func MarshallMessageOfInterestMap(tagmap map[protocol.Tag]bool) []byte
- func ParseHostOrURL(addr string) (*url.URL, error)
- func SetUserAgentHeader(header http.Header)
- type Dialer
- type ForwardingPolicy
- type GossipNode
- type HTTPPeer
- type HandlerFunc
- type IncomingMessage
- type LimitedReaderSlurper
- type MessageHandler
- type Multiplexer
- type NetPrioScheme
- type OutgoingMessage
- type Peer
- type PeerOption
- type PhoneBookEntryRoles
- type Phonebook
- type RequestLogger
- type RequestTracker
- func (rt *RequestTracker) Accept() (conn net.Conn, err error)
- func (rt *RequestTracker) Addr() net.Addr
- func (rt *RequestTracker) Close() error
- func (rt *RequestTracker) GetRequestConnection(request *http.Request) net.Conn
- func (rt *RequestTracker) GetTrackedRequest(request *http.Request) (trackedRequest *TrackerRequest)
- func (rt *RequestTracker) Listener(listener net.Listener) net.Listener
- func (rt *RequestTracker) ServeHTTP(response http.ResponseWriter, request *http.Request)
- type Response
- type Tag
- type TaggedMessageHandler
- type Topic
- type Topics
- type TrackerRequest
- type UnicastPeer
- type WebsocketNetwork
- func (wn *WebsocketNetwork) Address() (string, bool)
- func (wn *WebsocketNetwork) Broadcast(ctx context.Context, tag protocol.Tag, data []byte, wait bool, except Peer) error
- func (wn *WebsocketNetwork) BroadcastArray(ctx context.Context, tags []protocol.Tag, data [][]byte, wait bool, ...) error
- func (wn *WebsocketNetwork) ClearHandlers()
- func (wn *WebsocketNetwork) Disconnect(node Peer)
- func (wn *WebsocketNetwork) DisconnectPeers()
- func (wn *WebsocketNetwork) GetHTTPRequestConnection(request *http.Request) (conn net.Conn)
- func (wn *WebsocketNetwork) GetPeerData(peer Peer, key string) interface{}
- func (wn *WebsocketNetwork) GetPeers(options ...PeerOption) []Peer
- func (wn *WebsocketNetwork) GetRoundTripper() http.RoundTripper
- func (wn *WebsocketNetwork) NumPeers() int
- func (wn *WebsocketNetwork) OnNetworkAdvance()
- func (wn *WebsocketNetwork) PublicAddress() string
- func (wn *WebsocketNetwork) Ready() chan struct{}
- func (wn *WebsocketNetwork) RegisterHTTPHandler(path string, handler http.Handler)
- func (wn *WebsocketNetwork) RegisterHandlers(dispatch []TaggedMessageHandler)
- func (wn *WebsocketNetwork) RegisterMessageInterest(t protocol.Tag) error
- func (wn *WebsocketNetwork) Relay(ctx context.Context, tag protocol.Tag, data []byte, wait bool, except Peer) error
- func (wn *WebsocketNetwork) RelayArray(ctx context.Context, tags []protocol.Tag, data [][]byte, wait bool, ...) error
- func (wn *WebsocketNetwork) RequestConnectOutgoing(replace bool, quit <-chan struct{})
- func (wn *WebsocketNetwork) ServeHTTP(response http.ResponseWriter, request *http.Request)
- func (wn *WebsocketNetwork) SetPeerData(peer Peer, key string, value interface{})
- func (wn *WebsocketNetwork) SetPrioScheme(s NetPrioScheme)
- func (wn *WebsocketNetwork) Start()
- func (wn *WebsocketNetwork) Stop()
- func (wn *WebsocketNetwork) SubstituteGenesisID(rawURL string) string
Constants ¶
const AddressHeader = "X-Algorand-Location"
AddressHeader HTTP header by which an inbound connection reports its public address
const (
ErrorKey = "Error" // used for passing an error message
)
Constant strings used as keys for topics
const GenesisHeader = "X-Algorand-Genesis"
GenesisHeader HTTP header for genesis id to make sure we're on the same chain
const GossipNetworkPath = "/v1/{genesisID}/gossip"
GossipNetworkPath is the URL path to connect to the websocket gossip node at. Contains {genesisID} param to be handled by gorilla/mux
const InstanceNameHeader = "X-Algorand-InstanceName"
InstanceNameHeader HTTP header by which an inbound connection reports an ID to distinguish multiple local nodes.
const MaxInt = int((^uint(0)) >> 1)
MaxInt is the maximum int which might be int32 or int64
const NodeRandomHeader = "X-Algorand-NodeRandom"
NodeRandomHeader HTTP header that a node uses to make sure it's not talking to itself
const PhoneBookEntryArchiverRole = 2
PhoneBookEntryArchiverRole used for all the archivers that are provided via the archive SRV record.
const PhoneBookEntryRelayRole = 1
PhoneBookEntryRelayRole used for all the relays that are provided either via the coinbootstrap SRV record or via a configuration file.
const PriorityChallengeHeader = "X-Algorand-PriorityChallenge"
PriorityChallengeHeader HTTP header informs a client about the challenge it should sign to increase network priority.
const ProtocolAcceptVersionHeader = "X-Algorand-Accept-Version"
ProtocolAcceptVersionHeader HTTP header for accept protocol version. Client use this to advertise supported protocol versions.
const ProtocolVersion = "2.1"
ProtocolVersion is the current version attached to the ProtocolVersionHeader header
Version history: * 1 Catchup service over websocket connections with unicast messages between peers * 2.1 Introducted topic key/data pairs and enabled services over the gossip connections
const ProtocolVersionHeader = "X-Algorand-Version"
ProtocolVersionHeader HTTP header for protocol version.
const TelemetryIDHeader = "X-Algorand-TelId"
TelemetryIDHeader HTTP header for telemetry-id for logging
const TooManyRequestsRetryAfterHeader = "Retry-After"
TooManyRequestsRetryAfterHeader HTTP header let the client know when to make the next connection attempt
const UserAgentHeader = "User-Agent"
UserAgentHeader is the HTTP header identify the user agent.
Variables ¶
var ErrConnectionQueueingTimeout = errors.New("rateLimitingTransport: queueing timeout")
ErrConnectionQueueingTimeout indicates that we've exceeded the time allocated for queueing the current request before the request attempt could be made.
var ErrIncomingMsgTooLarge = errors.New("read limit exceeded")
ErrIncomingMsgTooLarge is returned when an incoming message is too large
var HostColonPortPattern = regexp.MustCompile("^[^:]+:\\d+$")
HostColonPortPattern matches "^[^:]+:\\d+$" e.g. "foo.com.:1234"
var SupportedProtocolVersions = []string{"2.1"}
SupportedProtocolVersions contains the list of supported protocol versions by this node ( in order of preference ).
Functions ¶
func MarshallMessageOfInterest ¶
MarshallMessageOfInterest generate a message of interest message body for a given set of message tags.
func MarshallMessageOfInterestMap ¶
MarshallMessageOfInterestMap generates a message of interest message body for the message tags that map to "true" in the map argument.
func ParseHostOrURL ¶
ParseHostOrURL handles "host:port" or a full URL. Standard library net/url.Parse chokes on "host:port".
func SetUserAgentHeader ¶
SetUserAgentHeader adds the User-Agent header to the provided heades map.
Types ¶
type Dialer ¶
type Dialer struct {
// contains filtered or unexported fields
}
Dialer establish tcp-level connection with the destination
type ForwardingPolicy ¶
type ForwardingPolicy int
ForwardingPolicy is an enum indicating to whom we should send a message
const ( // Ignore - discard (don't forward) Ignore ForwardingPolicy = iota // Disconnect - disconnect from the peer that sent this message Disconnect // Broadcast - forward to everyone (except the sender) Broadcast // Respond - reply to the sender Respond )
type GossipNode ¶
type GossipNode interface { Address() (string, bool) Broadcast(ctx context.Context, tag protocol.Tag, data []byte, wait bool, except Peer) error BroadcastArray(ctx context.Context, tag []protocol.Tag, data [][]byte, wait bool, except Peer) error Relay(ctx context.Context, tag protocol.Tag, data []byte, wait bool, except Peer) error RelayArray(ctx context.Context, tag []protocol.Tag, data [][]byte, wait bool, except Peer) error Disconnect(badnode Peer) DisconnectPeers() Ready() chan struct{} // RegisterHTTPHandler path accepts gorilla/mux path annotations RegisterHTTPHandler(path string, handler http.Handler) // RequestConnectOutgoing asks the system to actually connect to peers. // `replace` optionally drops existing connections before making new ones. // `quit` chan allows cancellation. TODO: use `context` RequestConnectOutgoing(replace bool, quit <-chan struct{}) // Get a list of Peers we could potentially send a direct message to. GetPeers(options ...PeerOption) []Peer // Start threads, listen on sockets. Start() // Close sockets. Stop threads. Stop() // RegisterHandlers adds to the set of given message handlers. RegisterHandlers(dispatch []TaggedMessageHandler) // ClearHandlers deregisters all the existing message handlers. ClearHandlers() // GetRoundTripper returns a Transport that would limit the number of outgoing connections. GetRoundTripper() http.RoundTripper // OnNetworkAdvance notifies the network library that the agreement protocol was able to make a notable progress. // this is the only indication that we have that we haven't formed a clique, where all incoming messages // arrive very quickly, but might be missing some votes. The usage of this call is expected to have similar // characteristics as with a watchdog timer. OnNetworkAdvance() // GetHTTPRequestConnection returns the underlying connection for the given request. Note that the request must be the same // request that was provided to the http handler ( or provide a fallback Context() to that ) GetHTTPRequestConnection(request *http.Request) (conn net.Conn) // RegisterMessageInterest notifies the network library that this node // wants to receive messages with the specified tag. This will cause // this node to send corresponding MsgOfInterest notifications to any // newly connecting peers. This should be called before the network // is started. RegisterMessageInterest(protocol.Tag) error // SubstituteGenesisID substitutes the "{genesisID}" with their network-specific genesisID. SubstituteGenesisID(rawURL string) string // GetPeerData returns a value stored by SetPeerData GetPeerData(peer Peer, key string) interface{} // SetPeerData attaches a piece of data to a peer. // Other services inside go-algorand may attach data to a peer that gets garbage collected when the peer is closed. SetPeerData(peer Peer, key string, value interface{}) }
GossipNode represents a node in the gossip network
func NewWebsocketGossipNode ¶
func NewWebsocketGossipNode(log logging.Logger, config config.Local, phonebookAddresses []string, genesisID string, networkID protocol.NetworkID) (gn GossipNode, err error)
NewWebsocketGossipNode constructs a websocket network node and returns it as a GossipNode interface implementation
type HTTPPeer ¶
HTTPPeer is what the opaque Peer might be. If you get an opaque Peer handle from a GossipNode, maybe try a .(HTTPPeer) type assertion on it.
type HandlerFunc ¶
type HandlerFunc func(message IncomingMessage) OutgoingMessage
HandlerFunc represents an implemenation of the MessageHandler interface
func (HandlerFunc) Handle ¶
func (f HandlerFunc) Handle(message IncomingMessage) OutgoingMessage
Handle implements MessageHandler.Handle, calling the handler with the IncomingKessage and returning the OutgoingMessage
type IncomingMessage ¶
type IncomingMessage struct { Sender Peer Tag Tag Data []byte Err error Net GossipNode // Received is time.Time.UnixNano() Received int64 // contains filtered or unexported fields }
IncomingMessage represents a message arriving from some peer in our p2p network
type LimitedReaderSlurper ¶
type LimitedReaderSlurper struct {
// contains filtered or unexported fields
}
LimitedReaderSlurper collects bytes from an io.Reader, but stops if a limit is reached.
func MakeLimitedReaderSlurper ¶
func MakeLimitedReaderSlurper(baseAllocation, maxAllocation uint64) *LimitedReaderSlurper
MakeLimitedReaderSlurper creates a LimitedReaderSlurper instance with the provided base and max memory allocations.
func (*LimitedReaderSlurper) Bytes ¶
func (s *LimitedReaderSlurper) Bytes() []byte
Bytes returns a copy of all the collected data
func (*LimitedReaderSlurper) Read ¶
func (s *LimitedReaderSlurper) Read(reader io.Reader) error
Read does repeated Read()s on the io.Reader until it gets io.EOF. Returns underlying error or ErrIncomingMsgTooLarge if limit reached. Returns a nil error if the underlying io.Reader returned io.EOF.
func (*LimitedReaderSlurper) Reset ¶
func (s *LimitedReaderSlurper) Reset()
Reset clears the buffered data
func (*LimitedReaderSlurper) Size ¶
func (s *LimitedReaderSlurper) Size() (size uint64)
Size returs the current total size of contained chunks read from io.Reader
type MessageHandler ¶
type MessageHandler interface {
Handle(message IncomingMessage) OutgoingMessage
}
MessageHandler takes a IncomingMessage (e.g., vote, transaction), processes it, and returns what (if anything) to send to the network in response. The ForwardingPolicy field of the returned OutgoingMessage indicates whether to reply directly to the sender (unicast), propagate to everyone except the sender (broadcast), or do nothing (ignore).
type Multiplexer ¶
type Multiplexer struct {
// contains filtered or unexported fields
}
Multiplexer is a message handler that sorts incoming messages by Tag and passes them along to the relevant message handler for that type of message.
func MakeMultiplexer ¶
func MakeMultiplexer(log logging.Logger) *Multiplexer
MakeMultiplexer creates an empty Multiplexer
func (*Multiplexer) ClearHandlers ¶
func (m *Multiplexer) ClearHandlers(excludeTags []Tag)
ClearHandlers deregisters all the existing message handlers other than the one provided in the excludeTags list
func (*Multiplexer) Handle ¶
func (m *Multiplexer) Handle(msg IncomingMessage) OutgoingMessage
Handle is the "input" side of the multiplexer. It dispatches the message to the previously defined handler.
func (*Multiplexer) RegisterHandlers ¶
func (m *Multiplexer) RegisterHandlers(dispatch []TaggedMessageHandler)
RegisterHandlers registers the set of given message handlers.
type NetPrioScheme ¶
type NetPrioScheme interface { NewPrioChallenge() string MakePrioResponse(challenge string) []byte VerifyPrioResponse(challenge string, response []byte) (basics.Address, error) GetPrioWeight(addr basics.Address) uint64 }
NetPrioScheme is an implementation of network connection priorities based on a challenge-response protocol.
type OutgoingMessage ¶
type OutgoingMessage struct { Action ForwardingPolicy Tag Tag Payload []byte Topics Topics }
OutgoingMessage represents a message we want to send.
func Propagate ¶
func Propagate(msg IncomingMessage) OutgoingMessage
Propagate is a convenience function to save typing in the common case of a message handler telling us to propagate an incoming message "return network.Propagate(msg)" instead of "return network.OutgoingMsg{network.Broadcast, msg.Tag, msg.Data}"
type PeerOption ¶
type PeerOption int
PeerOption allows users to specify a subset of peers to query
const ( // PeersConnectedOut specifies all peers with outgoing connections PeersConnectedOut PeerOption = iota // PeersConnectedIn specifies all peers with inbound connections PeersConnectedIn PeerOption = iota // PeersPhonebookRelays specifies all relays in the phonebook PeersPhonebookRelays PeerOption = iota // PeersPhonebookArchivers specifies all archivers in the phonebook PeersPhonebookArchivers PeerOption = iota )
type PhoneBookEntryRoles ¶
type PhoneBookEntryRoles int
PhoneBookEntryRoles defines the roles that a single entry on the phonebook can take. currently, we have two roles : relay role and archiver role, which are mutually exclusive.
type Phonebook ¶
type Phonebook interface { // GetAddresses(N) returns up to N addresses, but may return fewer GetAddresses(n int, role PhoneBookEntryRoles) []string // UpdateRetryAfter updates the retry-after field for the entries matching the given address UpdateRetryAfter(addr string, retryAfter time.Time) // GetConnectionWaitTime will calculate and return the wait // time to prevent exceeding connectionsRateLimitingCount. // The connection should be established when the waitTime is 0. // It will register a provisional next connection time when the waitTime is 0. // The provisional time should be updated after the connection with UpdateConnectionTime GetConnectionWaitTime(addr string) (addrInPhonebook bool, waitTime time.Duration, provisionalTime time.Time) // UpdateConnectionTime will update the provisional connection time. // Returns true of the addr was in the phonebook UpdateConnectionTime(addr string, provisionalTime time.Time) bool // ReplacePeerList merges a set of addresses with that passed in for networkName // new entries in dnsAddresses are being added // existing items that aren't included in dnsAddresses are being removed // matching entries don't change ReplacePeerList(dnsAddresses []string, networkName string, role PhoneBookEntryRoles) // ExtendPeerList adds unique addresses to this set of addresses ExtendPeerList(more []string, networkName string, role PhoneBookEntryRoles) }
Phonebook stores or looks up addresses of nodes we might contact
type RequestLogger ¶
type RequestLogger struct {
// contains filtered or unexported fields
}
RequestLogger is a middleware helps logging all the incoming http requests. The intended use is to place it at the bottom of the http processing. It will capture the status codes set by the upsteam handlers and write the request info/response to the logger.
func (*RequestLogger) ServeHTTP ¶
func (rl *RequestLogger) ServeHTTP(writer http.ResponseWriter, request *http.Request)
this is the http entry point for the request logger.
func (*RequestLogger) SetStatusCode ¶
func (rl *RequestLogger) SetStatusCode(writer http.ResponseWriter, statusCode int)
SetStatusCode sets the status code of a given response writer without writing it to the underlaying writer object.
type RequestTracker ¶
type RequestTracker struct {
// contains filtered or unexported fields
}
RequestTracker tracks the incoming request connections
func (*RequestTracker) Accept ¶
func (rt *RequestTracker) Accept() (conn net.Conn, err error)
Accept waits for and returns the next connection to the listener.
func (*RequestTracker) Addr ¶
func (rt *RequestTracker) Addr() net.Addr
Addr returns the listener's network address.
func (*RequestTracker) Close ¶
func (rt *RequestTracker) Close() error
Close closes the listener. Any blocked Accept operations will be unblocked and return errors.
func (*RequestTracker) GetRequestConnection ¶
func (rt *RequestTracker) GetRequestConnection(request *http.Request) net.Conn
GetRequestConnection return the underlying connection for the given request
func (*RequestTracker) GetTrackedRequest ¶
func (rt *RequestTracker) GetTrackedRequest(request *http.Request) (trackedRequest *TrackerRequest)
GetTrackedRequest return the tracked request
func (*RequestTracker) Listener ¶
func (rt *RequestTracker) Listener(listener net.Listener) net.Listener
Listener initialize the underlaying listener, and return the request tracker wrapping listener
func (*RequestTracker) ServeHTTP ¶
func (rt *RequestTracker) ServeHTTP(response http.ResponseWriter, request *http.Request)
type Response ¶
type Response struct {
Topics Topics
}
Response is the structure holding the response from the server
type TaggedMessageHandler ¶
type TaggedMessageHandler struct { Tag MessageHandler }
TaggedMessageHandler receives one type of broadcast messages
type Topic ¶
type Topic struct {
// contains filtered or unexported fields
}
Topic is a key-value pair
type Topics ¶
type Topics []Topic
Topics is an array of type Topic The maximum number of topics allowed is 32 Each topic key can be 64 characters long and cannot be size 0
func UnmarshallTopics ¶
UnmarshallTopics unmarshalls the topics from the byte array
func (Topics) MarshallTopics ¶
MarshallTopics serializes the topics into a byte array
type TrackerRequest ¶
type TrackerRequest struct {
// contains filtered or unexported fields
}
TrackerRequest hold the tracking data associated with a single request.
type UnicastPeer ¶
type UnicastPeer interface { GetAddress() string // Unicast sends the given bytes to this specific peer. Does not wait for message to be sent. Unicast(ctx context.Context, data []byte, tag protocol.Tag) error // Version returns the matching version from network.SupportedProtocolVersions Version() string Request(ctx context.Context, tag Tag, topics Topics) (resp *Response, e error) Respond(ctx context.Context, reqMsg IncomingMessage, topics Topics) (e error) }
UnicastPeer is another possible interface for the opaque Peer. It is possible that we can only initiate a connection to a peer over websockets.
type WebsocketNetwork ¶
type WebsocketNetwork struct { GenesisID string NetworkID protocol.NetworkID RandomID string // contains filtered or unexported fields }
WebsocketNetwork implements GossipNode
func NewWebsocketNetwork ¶
func NewWebsocketNetwork(log logging.Logger, config config.Local, phonebookAddresses []string, genesisID string, networkID protocol.NetworkID) (wn *WebsocketNetwork, err error)
NewWebsocketNetwork constructor for websockets based gossip network
func (*WebsocketNetwork) Address ¶
func (wn *WebsocketNetwork) Address() (string, bool)
Address returns a string and whether that is a 'final' address or guessed. Part of GossipNode interface
func (*WebsocketNetwork) Broadcast ¶
func (wn *WebsocketNetwork) Broadcast(ctx context.Context, tag protocol.Tag, data []byte, wait bool, except Peer) error
Broadcast sends a message. If except is not nil then we will not send it to that neighboring Peer. if wait is true then the call blocks until the packet has actually been sent to all neighbors.
func (*WebsocketNetwork) BroadcastArray ¶
func (wn *WebsocketNetwork) BroadcastArray(ctx context.Context, tags []protocol.Tag, data [][]byte, wait bool, except Peer) error
BroadcastArray sends an array of messages. If except is not nil then we will not send it to that neighboring Peer. if wait is true then the call blocks until the packet has actually been sent to all neighbors. TODO: add `priority` argument so that we don't have to guess it based on tag
func (*WebsocketNetwork) ClearHandlers ¶
func (wn *WebsocketNetwork) ClearHandlers()
ClearHandlers deregisters all the existing message handlers.
func (*WebsocketNetwork) Disconnect ¶
func (wn *WebsocketNetwork) Disconnect(node Peer)
Disconnect from a peer, probably due to protocol errors.
func (*WebsocketNetwork) DisconnectPeers ¶
func (wn *WebsocketNetwork) DisconnectPeers()
DisconnectPeers shuts down all connections
func (*WebsocketNetwork) GetHTTPRequestConnection ¶
func (wn *WebsocketNetwork) GetHTTPRequestConnection(request *http.Request) (conn net.Conn)
GetHTTPRequestConnection returns the underlying connection for the given request. Note that the request must be the same request that was provided to the http handler ( or provide a fallback Context() to that ) if the provided request has no associated connection, it returns nil. ( this should not happen for any http request that was registered by WebsocketNetwork )
func (*WebsocketNetwork) GetPeerData ¶
func (wn *WebsocketNetwork) GetPeerData(peer Peer, key string) interface{}
GetPeerData returns the peer data associated with a particular key.
func (*WebsocketNetwork) GetPeers ¶
func (wn *WebsocketNetwork) GetPeers(options ...PeerOption) []Peer
GetPeers returns a snapshot of our Peer list, according to the specified options. Peers may be duplicated and refer to the same underlying node.
func (*WebsocketNetwork) GetRoundTripper ¶
func (wn *WebsocketNetwork) GetRoundTripper() http.RoundTripper
GetRoundTripper returns an http.Transport that limits the number of connection to comply with connectionsRateLimitingCount.
func (*WebsocketNetwork) NumPeers ¶
func (wn *WebsocketNetwork) NumPeers() int
NumPeers returns number of peers we connect to (all peers incoming and outbound).
func (*WebsocketNetwork) OnNetworkAdvance ¶
func (wn *WebsocketNetwork) OnNetworkAdvance()
OnNetworkAdvance notifies the network library that the agreement protocol was able to make a notable progress. this is the only indication that we have that we haven't formed a clique, where all incoming messages arrive very quickly, but might be missing some votes. The usage of this call is expected to have similar characteristics as with a watchdog timer.
func (*WebsocketNetwork) PublicAddress ¶
func (wn *WebsocketNetwork) PublicAddress() string
PublicAddress what we tell other nodes to connect to. Might be different than our locally percieved network address due to NAT/etc. Returns config "PublicAddress" if available, otherwise local addr.
func (*WebsocketNetwork) Ready ¶
func (wn *WebsocketNetwork) Ready() chan struct{}
Ready returns a chan that will be closed when we have a minimum number of peer connections active
func (*WebsocketNetwork) RegisterHTTPHandler ¶
func (wn *WebsocketNetwork) RegisterHTTPHandler(path string, handler http.Handler)
RegisterHTTPHandler path accepts gorilla/mux path annotations
func (*WebsocketNetwork) RegisterHandlers ¶
func (wn *WebsocketNetwork) RegisterHandlers(dispatch []TaggedMessageHandler)
RegisterHandlers registers the set of given message handlers.
func (*WebsocketNetwork) RegisterMessageInterest ¶
func (wn *WebsocketNetwork) RegisterMessageInterest(t protocol.Tag) error
RegisterMessageInterest notifies the network library that this node wants to receive messages with the specified tag. This will cause this node to send corresponding MsgOfInterest notifications to any newly connecting peers. This should be called before the network is started.
func (*WebsocketNetwork) Relay ¶
func (wn *WebsocketNetwork) Relay(ctx context.Context, tag protocol.Tag, data []byte, wait bool, except Peer) error
Relay message
func (*WebsocketNetwork) RelayArray ¶
func (wn *WebsocketNetwork) RelayArray(ctx context.Context, tags []protocol.Tag, data [][]byte, wait bool, except Peer) error
RelayArray relays array of messages
func (*WebsocketNetwork) RequestConnectOutgoing ¶
func (wn *WebsocketNetwork) RequestConnectOutgoing(replace bool, quit <-chan struct{})
RequestConnectOutgoing tries to actually do the connect to new peers. `replace` drop all connections first and find new peers.
func (*WebsocketNetwork) ServeHTTP ¶
func (wn *WebsocketNetwork) ServeHTTP(response http.ResponseWriter, request *http.Request)
ServerHTTP handles the gossip network functions over websockets
func (*WebsocketNetwork) SetPeerData ¶
func (wn *WebsocketNetwork) SetPeerData(peer Peer, key string, value interface{})
SetPeerData sets the peer data associated with a particular key.
func (*WebsocketNetwork) SetPrioScheme ¶
func (wn *WebsocketNetwork) SetPrioScheme(s NetPrioScheme)
SetPrioScheme specifies the network priority scheme for a network node
func (*WebsocketNetwork) Start ¶
func (wn *WebsocketNetwork) Start()
Start makes network connections and threads
func (*WebsocketNetwork) Stop ¶
func (wn *WebsocketNetwork) Stop()
Stop closes network connections and stops threads. Stop blocks until all activity on this node is done.
func (*WebsocketNetwork) SubstituteGenesisID ¶
func (wn *WebsocketNetwork) SubstituteGenesisID(rawURL string) string
SubstituteGenesisID substitutes the "{genesisID}" with their network-specific genesisID.