Documentation ¶
Index ¶
- type ClientNode
- func (n *ClientNode) ConsensusStatus(ctx context.Context, opts api.ConsensusStatusOptions) (*api.ConsensusStatus, error)
- func (n *ClientNode) Faucet(ctx context.Context, account *url.URL, opts api.FaucetOptions) (*api.Submission, error)
- func (n *ClientNode) FindService(ctx context.Context, opts api.FindServiceOptions) ([]*api.FindServiceResult, error)
- func (n *ClientNode) Metrics(ctx context.Context, opts api.MetricsOptions) (*api.Metrics, error)
- func (n *ClientNode) NetworkStatus(ctx context.Context, opts api.NetworkStatusOptions) (*api.NetworkStatus, error)
- func (n *ClientNode) NodeInfo(ctx context.Context, opts api.NodeInfoOptions) (*api.NodeInfo, error)
- func (n *ClientNode) Query(ctx context.Context, scope *url.URL, query api.Query) (api.Record, error)
- func (n *ClientNode) Submit(ctx context.Context, envelope *messaging.Envelope, opts api.SubmitOptions) ([]*api.Submission, error)
- func (n *ClientNode) Subscribe(ctx context.Context, opts api.SubscribeOptions) (<-chan api.Event, error)
- func (n *ClientNode) Validate(ctx context.Context, envelope *messaging.Envelope, opts api.ValidateOptions) ([]*api.Submission, error)
- type MessageStreamHandler
- type Node
- func (n *Node) Addresses() []multiaddr.Multiaddr
- func (n *Node) Close() error
- func (n *Node) ConnectDirectly(m *Node) error
- func (n *Node) Connector() dial.Connector
- func (n *Node) DialNetwork() message.Dialer
- func (n *Node) DialSelf() message.Dialer
- func (n *Node) ID() peer.ID
- func (n *Node) RegisterService(sa *api.ServiceAddress, handler MessageStreamHandler) bool
- func (n *Node) Services() *nodeService
- func (n *Node) Tracker() dial.Tracker
- func (s *Node) WaitForService(ctx context.Context, addr multiaddr.Multiaddr) error
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientNode ¶
type ClientNode struct { *Node // contains filtered or unexported fields }
ClientNode is a peer to peer node. ClientNode acts as a client, routing messages to its peers, and as a server that can register services to the network.
func NewClient ¶
func NewClient(opts Options) (*ClientNode, error)
NewClient creates a new node. NewClient waits for the Network service of the Directory network to be available and queries it to determine the routing table. Thus NewClient must not be used by the core nodes themselves.
func NewClientWith ¶
func NewClientWith(node *Node) (*ClientNode, error)
NewClientWith creates a new client for the given node. NewClientWith waits for the Network service of the Directory network to be available and queries it to determine the routing table. Thus NewClientWith must not be used by the core nodes themselves.
func (*ClientNode) ConsensusStatus ¶
func (n *ClientNode) ConsensusStatus(ctx context.Context, opts api.ConsensusStatusOptions) (*api.ConsensusStatus, error)
ConsensusStatus implements api.ConsensusService.ConsensusStatus.
func (*ClientNode) Faucet ¶
func (n *ClientNode) Faucet(ctx context.Context, account *url.URL, opts api.FaucetOptions) (*api.Submission, error)
Faucet implements api.Faucet.Faucet.
func (*ClientNode) FindService ¶
func (n *ClientNode) FindService(ctx context.Context, opts api.FindServiceOptions) ([]*api.FindServiceResult, error)
FindService implements api.NodeService.FindService.
func (*ClientNode) Metrics ¶
func (n *ClientNode) Metrics(ctx context.Context, opts api.MetricsOptions) (*api.Metrics, error)
Metrics implements api.MetricsService.Metrics.
func (*ClientNode) NetworkStatus ¶
func (n *ClientNode) NetworkStatus(ctx context.Context, opts api.NetworkStatusOptions) (*api.NetworkStatus, error)
NetworkStatus implements api.NetworkService.NetworkStatus.
func (*ClientNode) NodeInfo ¶
func (n *ClientNode) NodeInfo(ctx context.Context, opts api.NodeInfoOptions) (*api.NodeInfo, error)
NodeInfo implements api.NodeService.NodeInfo.
func (*ClientNode) Query ¶
func (n *ClientNode) Query(ctx context.Context, scope *url.URL, query api.Query) (api.Record, error)
Query implements api.Querier.Query.
func (*ClientNode) Submit ¶
func (n *ClientNode) Submit(ctx context.Context, envelope *messaging.Envelope, opts api.SubmitOptions) ([]*api.Submission, error)
Submit implements api.Submitter.Submit.
func (*ClientNode) Subscribe ¶
func (n *ClientNode) Subscribe(ctx context.Context, opts api.SubscribeOptions) (<-chan api.Event, error)
Subscribe implements api.EventService.Subscribe.
func (*ClientNode) Validate ¶
func (n *ClientNode) Validate(ctx context.Context, envelope *messaging.Envelope, opts api.ValidateOptions) ([]*api.Submission, error)
Validate implements api.Validator.Validate.
type MessageStreamHandler ¶
A MessageStreamHandler handles an incoming message.Stream.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node implements peer-to-peer routing of API v3 messages over via binary message transport.
func (*Node) Addresses ¶
func (n *Node) Addresses() []multiaddr.Multiaddr
Addresses lists the node's addresses.
func (*Node) ConnectDirectly ¶
ConnectDirectly connects this node directly to another node.
func (*Node) DialNetwork ¶
DialNetwork returns a message.MultiDialer that opens a stream to a node that can provides a given service.
func (*Node) DialSelf ¶
DialSelf returns a message.Dialer that always returns a stream for the current node.
func (*Node) RegisterService ¶
func (n *Node) RegisterService(sa *api.ServiceAddress, handler MessageStreamHandler) bool
RegisterService registers a service handler and registers the service with the network.
func (*Node) WaitForService ¶
WaitForService IS NOT RELIABLE.
WaitForService blocks until the given service is available. WaitForService will return once the service is registered on the current node or until the node is informed of a peer with the given service. WaitForService will return immediately if the service is already registered or known.
type Options ¶
type Options struct { // Network is the network the node is a part of. An empty Network indicates // the node is not part of any network. Network string // Listen is an array of addresses to listen on. Listen []multiaddr.Multiaddr // BootstrapPeers is an array of addresses of the bootstrap peers to connect // to on bootup. BootstrapPeers []multiaddr.Multiaddr // Key is the node's private key. If Key is omitted, the node will // generate a new key. Key ed25519.PrivateKey // DiscoveryMode determines how the node responds to peer discovery // requests. DiscoveryMode dht.ModeOpt // External is the node's external address External multiaddr.Multiaddr // EnablePeerTracker enables the peer tracker to reduce the impact of // mis-configured peers. This is currently experimental. EnablePeerTracker bool PeerDatabase string PeerScanFrequency time.Duration PeerPersistFrequency time.Duration }
Options are options for creating a Node.