Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller interface {
// SendMessage send message to nodeID.
SendMessage(nodeID core.RecordRef, name string, msg core.SignedMessage) ([]byte, error)
// RemoteProcedureRegister register remote procedure that will be executed when message is received.
RemoteProcedureRegister(name string, method core.RemoteProcedure)
// SendCascadeMessage sends a message from MessageBus to a cascade of nodes.
SendCascadeMessage(data core.Cascade, method string, msg core.SignedMessage) error
// Bootstrap init bootstrap process: 1. Connect to discovery node; 2. Reconnect to new discovery node if redirected.
Bootstrap() error
// AnalyzeNetwork legacy method for old DHT network (should be removed in new network).
AnalyzeNetwork() error
// Authorize start authorization process on discovery node.
Authorize() error
// ResendPulseToKnownHosts resend pulse when we receive pulse from pulsar daemon.
ResendPulseToKnownHosts(pulse core.Pulse)
// GetNodeID get self node id (should be removed in far future).
GetNodeID() core.RecordRef
// Inject inject components.
Inject(components core.Components)
}
Controller contains network logic.
type Future ¶
type Future interface {
GetRequest() Request
Response() <-chan Response
GetResponse(duration time.Duration) (Response, error)
}
Future allows to handle responses to a previously sent request.
type HostNetwork ¶
type HostNetwork interface {
// Start listening to network requests.
Start()
// Stop listening to network requests.
Stop()
// PublicAddress returns public address that can be published for all nodes.
PublicAddress() string
// SendRequest send request to a remote node.
SendRequest(request Request, receiver core.RecordRef) (Future, error)
// RegisterRequestHandler register a handler function to process incoming requests of a specific type.
RegisterRequestHandler(t types.PacketType, handler RequestHandler)
// NewRequestBuilder create packet builder for an outgoing request with sender set to current node.
NewRequestBuilder() RequestBuilder
// BuildResponse create response to an incoming request with Data set to responseData
BuildResponse(request Request, responseData interface{}) Response
}
HostNetwork simple interface to send network requests and process network responses.
type NodeKeeper ¶
type NodeKeeper interface {
core.NodeNetwork
// AddActiveNodes add active nodes.
AddActiveNodes([]*core.Node)
// SetPulse sets internal PulseNumber to number. Returns true if set was successful, false if number is less
// or equal to internal PulseNumber. If set is successful, returns collected unsync list and starts collecting new unsync list.
SetPulse(number core.PulseNumber) (bool, UnsyncList)
// Sync initiates transferring syncCandidates -> sync, sync -> active.
// If number is less than internal PulseNumber then ignore Sync.
Sync(syncCandidates []*core.Node, number core.PulseNumber)
// AddUnsync add unsync node to the unsync list. Returns channel that receives active node on successful sync.
// Channel will return nil node if added node has not passed the consensus.
// Returns error if current node is not active and cannot participate in consensus.
AddUnsync(nodeID core.RecordRef, roles []core.NodeRole, address string,
version string) (chan *core.Node, error)
// GetUnsyncHolder get unsync list executed in consensus for specific pulse.
// 1. If pulse is less than internal NodeKeeper pulse, returns error.
// 2. If pulse is equal to internal NodeKeeper pulse, returns unsync list holder for currently executed consensus.
// 3. If pulse is more than internal NodeKeeper pulse, blocks till next SetPulse or duration timeout and then acts like in par. 2.
GetUnsyncHolder(pulse core.PulseNumber, duration time.Duration) (UnsyncList, error)
}
NodeKeeper manages unsync, sync and active lists.
type NodeUnsyncHash ¶
NodeUnsyncHash data needed for consensus.
type Packet ¶
type Packet interface {
GetSender() core.RecordRef
GetSenderHost() *host.Host
GetType() types.PacketType
GetData() interface{}
}
Packet is a packet that is transported via network by HostNetwork.
type RequestBuilder ¶
type RequestBuilder interface {
Type(packetType types.PacketType) RequestBuilder
Data(data interface{}) RequestBuilder
Build() Request
}
RequestBuilder allows to build a Request.
type RequestHandler ¶
RequestHandler handler function to process incoming requests from network.
type Response ¶
type Response Packet
Response is a packet that is received in response to a previously sent Request.
type UnsyncList ¶
type UnsyncList interface {
// GetUnsync returns list of local unsync nodes. This list is created.
GetUnsync() []*core.Node
// GetPulse returns actual pulse for current consensus process.
GetPulse() core.PulseNumber
// SetHash sets hash of unsync lists for each node of consensus.
SetHash([]*NodeUnsyncHash)
// GetHash get hash of unsync lists for each node of If hash is not calculated yet, then this call blocks
// until the hash is calculated with SetHash() call.
GetHash(blockTimeout time.Duration) ([]*NodeUnsyncHash, error)
// AddUnsyncList add unsync list for remote ref.
AddUnsyncList(ref core.RecordRef, unsync []*core.Node)
// AddUnsyncHash add unsync hash for remote ref.
AddUnsyncHash(ref core.RecordRef, hash []*NodeUnsyncHash)
// GetUnsyncList get unsync list for remote ref.
GetUnsyncList(ref core.RecordRef) ([]*core.Node, bool)
// GetUnsyncHash get unsync hash for remote ref.
GetUnsyncHash(ref core.RecordRef) ([]*NodeUnsyncHash, bool)
}
Directories
¶
| Path | Synopsis |
|---|---|
|
Package consensus provides BFT-like algorithm to distribute list of records between participants
|
Package consensus provides BFT-like algorithm to distribute list of records between participants |
|
Package hostnetwork is an implementation of Kademlia DHT.
|
Package hostnetwork is an implementation of Kademlia DHT. |
|
routing
Package routing implements Kademlia hash tables with XOR distance metrics.
|
Package routing implements Kademlia hash tables with XOR distance metrics. |
|
rpc
Package rpc allows higher level components to register methods that can be called by other network hosts.
|
Package rpc allows higher level components to register methods that can be called by other network hosts. |
|
store
Package store provides interfaces and default in-memory implementation of storage for DHT metadata.
|
Package store provides interfaces and default in-memory implementation of storage for DHT metadata. |
|
Package transport provides network transport interface.
|
Package transport provides network transport interface. |
|
connection
Package connection encapsulates connection creation process and provides connection factories.
|
Package connection encapsulates connection creation process and provides connection factories. |
|
host
Package host is a fundamental part of networking system.
|
Package host is a fundamental part of networking system. |
|
packet
Package packet provides network messaging protocol and serialization layer.
|
Package packet provides network messaging protocol and serialization layer. |
|
relay
Package relay is an implementation of relay mechanism.
|
Package relay is an implementation of relay mechanism. |
|
resolver
Package resolver provides interface (and default implementation) to retrieve public network address.
|
Package resolver provides interface (and default implementation) to retrieve public network address. |
Click to show internal directories.
Click to hide internal directories.