Documentation
¶
Overview ¶
Package onet is the Overlay Network which offers a simple framework for generating your own distributed systems. It is based on a description of your protocol and offers sending and receiving messages, handling trees and host-lists, and easy deploying to Localhost, Deterlab or a real-system.
ONet is based on the following pieces:
- Local* - offers the user-interface to the API for deploying your protocol locally and for testing
- Node / ProtocolInstance - gives an interface to define your protocol
- Server - hold states for the different parts of Onet
- network - uses secured connections between hosts
If you just want to use an existing protocol, usually the ONet-part is enough. If you want to create your own protocol, you have to learn how to use the ProtocolInstance.
Index ¶
- Constants
- Variables
- func InformAllServersStopped()
- func InformServerStarted()
- func NewPrivIdentity(suite network.Suite, port int) (kyber.Scalar, *network.ServerIdentity)
- func ReadTomlConfig(conf interface{}, filename string, dirOpt ...string) error
- func RegisterMessageProxy(n NewMessageProxy)
- func SimulationRegister(name string, sim simulationCreate)
- func UnregisterService(name string) error
- func WriteTomlConfig(conf interface{}, filename string, dirOpt ...string)
- type BidirectionalStreamer
- type CertificateReloader
- type Client
- func (c *Client) Close() error
- func (c *Client) Rx() uint64
- func (c *Client) Send(dst *network.ServerIdentity, path string, buf []byte) ([]byte, error)
- func (c *Client) SendProtobuf(dst *network.ServerIdentity, msg interface{}, ret interface{}) error
- func (c *Client) SendProtobufParallel(nodes []*network.ServerIdentity, msg interface{}, ret interface{}, ...) (*network.ServerIdentity, error)
- func (c *Client) SendProtobufParallelWithDecoder(nodes []*network.ServerIdentity, msg interface{}, ret interface{}, ...) (*network.ServerIdentity, error)
- func (c *Client) SendToAll(dst *Roster, path string, buf []byte) ([][]byte, error)
- func (c *Client) Stream(dst *network.ServerIdentity, msg interface{}) (StreamingConn, error)
- func (c *Client) Suite() network.Suite
- func (c *Client) Tx() uint64
- type ConfigMsg
- type Context
- func (c *Context) CreateProtocol(name string, t *Tree) (ProtocolInstance, error)
- func (c *Context) GetAdditionalBucket(name []byte) (*bbolt.DB, []byte)
- func (c *Context) GetValidPeers(peerID network.PeerSetID) []...
- func (c *Context) Load(key []byte) (interface{}, error)
- func (c *Context) LoadRaw(key []byte) ([]byte, error)
- func (c *Context) LoadVersion() (int, error)
- func (c *Context) NewPeerSetID(data []byte) network.PeerSetID
- func (c *Context) NewTreeNodeInstance(t *Tree, tn *TreeNode, protoName string) *TreeNodeInstance
- func (c *Context) ProtocolRegister(name string, protocol NewProtocol) (ProtocolID, error)
- func (c *Context) RegisterMessageProxy(m MessageProxy)
- func (c *Context) RegisterProcessor(p network.Processor, msgType network.MessageTypeID)
- func (c *Context) RegisterProcessorFunc(msgType network.MessageTypeID, fn func(*network.Envelope) error)
- func (c *Context) RegisterProtocolInstance(pi ProtocolInstance) error
- func (c *Context) RegisterStatusReporter(name string, s StatusReporter)
- func (c *Context) ReportStatus() map[string]*Status
- func (c *Context) Save(key []byte, data interface{}) error
- func (c *Context) SaveVersion(version int) error
- func (c *Context) SendRaw(si *network.ServerIdentity, msg interface{}) error
- func (c *Context) ServerIdentity() *network.ServerIdentity
- func (c *Context) Service(name string) Service
- func (c *Context) ServiceID() ServiceID
- func (c *Context) SetValidPeers(peerID network.PeerSetID, peers []*network.ServerIdentity)
- func (c *Context) String() string
- func (c *Context) Suite() network.Suite
- type ContextDB
- type Decoder
- type GenericConfig
- type LeakyTestCheck
- type LocalTest
- func (l *LocalTest) CloseAll()
- func (l *LocalTest) CreateProtocol(name string, t *Tree) (ProtocolInstance, error)
- func (l *LocalTest) GenBigTree(nbrTreeNodes, nbrServers, bf int, register bool) ([]*Server, *Roster, *Tree)
- func (l *LocalTest) GenRosterFromHost(servers ...*Server) *Roster
- func (l *LocalTest) GenServers(n int) []*Server
- func (l *LocalTest) GenTree(n int, register bool) ([]*Server, *Roster, *Tree)
- func (l *LocalTest) GetPrivate(c *Server) kyber.Scalar
- func (l *LocalTest) GetServices(servers []*Server, sid ServiceID) []Service
- func (l *LocalTest) GetTreeNodeInstances(id network.ServerIdentityID) []*TreeNodeInstance
- func (l *LocalTest) MakeSRS(s network.Suite, nbr int, sid ServiceID) ([]*Server, *Roster, Service)
- func (l *LocalTest) NewClient(serviceName string) *Client
- func (l *LocalTest) NewClientKeep(serviceName string) *Client
- func (l *LocalTest) NewLocalServer(s network.Suite, port int) *Server
- func (l *LocalTest) NewServer(s network.Suite, port int) *Server
- func (l *LocalTest) NewTreeNodeInstance(tn *TreeNode, protName string) (*TreeNodeInstance, error)
- func (l *LocalTest) StartProtocol(name string, t *Tree) (ProtocolInstance, error)
- func (l *LocalTest) WaitDone(t time.Duration) error
- type MessageProxy
- type MsgHandler
- type NewMessageProxy
- type NewProtocol
- type NewServiceFunc
- type Overlay
- func (o *Overlay) Close()
- func (o *Overlay) CreateProtocol(name string, t *Tree, sid ServiceID) (ProtocolInstance, error)
- func (o *Overlay) NewTreeNodeInstanceFromProtoName(t *Tree, name string) *TreeNodeInstance
- func (o *Overlay) NewTreeNodeInstanceFromProtocol(t *Tree, tn *TreeNode, protoID ProtocolID, io MessageProxy) *TreeNodeInstance
- func (o *Overlay) NewTreeNodeInstanceFromService(t *Tree, tn *TreeNode, protoID ProtocolID, servID ServiceID, io MessageProxy) *TreeNodeInstance
- func (o *Overlay) Process(env *network.Envelope)
- func (o *Overlay) RegisterMessageProxy(m MessageProxy)
- func (o *Overlay) RegisterProtocolInstance(pi ProtocolInstance) error
- func (o *Overlay) RegisterTree(t *Tree)
- func (o *Overlay) Rx() uint64
- func (o *Overlay) SendToTreeNode(from *Token, to *TreeNode, msg network.Message, io MessageProxy, ...) (uint64, error)
- func (o *Overlay) ServerIdentity() *network.ServerIdentity
- func (o *Overlay) StartProtocol(name string, t *Tree, sid ServiceID) (ProtocolInstance, error)
- func (o *Overlay) TransmitMsg(onetMsg *ProtocolMsg, io MessageProxy) error
- func (o *Overlay) TreeNodeFromToken(t *Token) (*TreeNode, error)
- func (o *Overlay) TreeNodeFromTree(tree *Tree, id TreeNodeID) (*TreeNode, error)
- func (o *Overlay) Tx() uint64
- type OverlayMsg
- type ParallelOptions
- type ProtocolID
- type ProtocolInstance
- type ProtocolMsg
- type RequestRoster
- type RequestTree
- type ResponseTree
- type Roster
- func (ro *Roster) Concat(sis ...*network.ServerIdentity) *Roster
- func (ro *Roster) Contains(pubs []kyber.Point) bool
- func (ro *Roster) Equal(other *Roster) (bool, error)
- func (ro *Roster) GenerateBigNaryTree(N, nodes int) *Tree
- func (ro *Roster) GenerateBinaryTree() *Tree
- func (ro *Roster) GenerateNaryTree(N int) *Tree
- func (ro *Roster) GenerateNaryTreeWithRoot(N int, root *network.ServerIdentity) *Tree
- func (ro *Roster) GenerateStar() *Tree
- func (ro *Roster) Get(idx int) *network.ServerIdentity
- func (ro *Roster) GetID() (RosterID, error)
- func (ro Roster) IsRotation(target *Roster) bool
- func (ro *Roster) NewRosterWithRoot(root *network.ServerIdentity) *Roster
- func (ro *Roster) Publics() []kyber.Point
- func (ro *Roster) RandomServerIdentity() *network.ServerIdentity
- func (ro *Roster) RandomSubset(root *network.ServerIdentity, n int) *Roster
- func (ro *Roster) Search(eID network.ServerIdentityID) (int, *network.ServerIdentity)
- func (ro Roster) ServiceAggregate(name string) (kyber.Point, error)
- func (ro *Roster) ServicePublics(name string) []kyber.Point
- func (ro *Roster) Toml(suite network.Suite) *RosterToml
- type RosterID
- type RosterToml
- type RosterUnknown
- type RoundID
- type Server
- func (c *Server) Address() network.Address
- func (c *Server) Close() error
- func (c *Server) GetService(name string) Service
- func (c *Server) GetStatus() *Status
- func (c *Server) ProtocolRegister(name string, protocol NewProtocol) (ProtocolID, error)
- func (c *Server) Service(name string) Service
- func (c *Server) Start()
- func (c *Server) StartInBackground()
- func (c *Server) Suite() network.Suite
- func (c *Server) WaitStartup()
- type Service
- type ServiceID
- type ServiceProcessor
- func (p *ServiceProcessor) IsStreaming(path string) (bool, error)
- func (p *ServiceProcessor) NewProtocol(tn *TreeNodeInstance, conf *GenericConfig) (ProtocolInstance, error)
- func (p *ServiceProcessor) Process(env *network.Envelope)
- func (p *ServiceProcessor) ProcessClientRequest(req *http.Request, path string, buf []byte) ([]byte, *StreamingTunnel, error)
- func (p *ServiceProcessor) ProcessClientStreamRequest(req *http.Request, path string, clientInputs chan []byte) (chan []byte, error)
- func (p *ServiceProcessor) RegisterHandler(f interface{}) error
- func (p *ServiceProcessor) RegisterHandlers(procs ...interface{}) error
- func (p *ServiceProcessor) RegisterRESTHandler(f interface{}, namespace, method string, minVersion, maxVersion int) error
- func (p *ServiceProcessor) RegisterStreamingHandler(f interface{}) error
- func (p *ServiceProcessor) RegisterStreamingHandlers(procs ...interface{}) error
- type Simulation
- type SimulationBFTree
- type SimulationConfig
- type SimulationConfigFile
- type SimulationPrivateKey
- type Status
- type StatusReporter
- type StreamingConn
- type StreamingReadOpts
- type StreamingTunnel
- type TestClose
- type Token
- type TokenID
- type Tree
- func (t *Tree) BinaryMarshaler() ([]byte, error)
- func (t *Tree) BinaryUnmarshaler(s network.Suite, b []byte) error
- func (t *Tree) Dump() string
- func (t *Tree) Equal(t2 *Tree) bool
- func (t *Tree) IsBinary(root *TreeNode) bool
- func (t *Tree) IsNary(root *TreeNode, N int) bool
- func (t *Tree) List() (ret []*TreeNode)
- func (t *Tree) MakeTreeMarshal() *TreeMarshal
- func (t *Tree) Marshal() ([]byte, error)
- func (t *Tree) Search(tn TreeNodeID) (ret *TreeNode)
- func (t *Tree) Size() int
- func (t *Tree) String() string
- func (t *Tree) UsesList() bool
- type TreeID
- type TreeMarshal
- type TreeNode
- func (t *TreeNode) AddChild(c *TreeNode)
- func (t *TreeNode) AggregatePublic(s network.Suite) kyber.Point
- func (t *TreeNode) Equal(t2 *TreeNode) bool
- func (t *TreeNode) IsConnectedTo(si *network.ServerIdentity) bool
- func (t *TreeNode) IsInTree(tree *Tree) bool
- func (t *TreeNode) IsLeaf() bool
- func (t *TreeNode) IsRoot() bool
- func (t *TreeNode) Name() string
- func (t *TreeNode) String() string
- func (t *TreeNode) SubtreeCount() int
- func (t *TreeNode) Visit(firstDepth int, fn func(depth int, n *TreeNode))
- type TreeNodeID
- type TreeNodeInfo
- type TreeNodeInstance
- func (n *TreeNodeInstance) Aggregate() kyber.Point
- func (n *TreeNodeInstance) Broadcast(msg interface{}) []error
- func (n *TreeNodeInstance) Children() []*TreeNode
- func (n *TreeNodeInstance) CloseHost() error
- func (n *TreeNodeInstance) CreateProtocol(name string, t *Tree) (ProtocolInstance, error)
- func (n *TreeNodeInstance) Dispatch() error
- func (n *TreeNodeInstance) Done()
- func (n *TreeNodeInstance) Host() *Server
- func (n *TreeNodeInstance) Index() int
- func (n *TreeNodeInstance) Info() string
- func (n *TreeNodeInstance) IsLeaf() bool
- func (n *TreeNodeInstance) IsRoot() bool
- func (n *TreeNodeInstance) List() []*TreeNode
- func (n *TreeNodeInstance) Multicast(msg interface{}, nodes ...*TreeNode) []error
- func (n *TreeNodeInstance) Name() string
- func (n *TreeNodeInstance) NodePublic(si *network.ServerIdentity) kyber.Point
- func (n *TreeNodeInstance) OnDoneCallback(fn func() bool)
- func (n *TreeNodeInstance) Parent() *TreeNode
- func (n *TreeNodeInstance) Private() kyber.Scalar
- func (n *TreeNodeInstance) ProcessProtocolMsg(msg *ProtocolMsg)
- func (n *TreeNodeInstance) ProtocolInstance() ProtocolInstance
- func (n *TreeNodeInstance) ProtocolName() string
- func (n *TreeNodeInstance) Public() kyber.Point
- func (n *TreeNodeInstance) Publics() []kyber.Point
- func (n *TreeNodeInstance) RegisterChannel(c interface{}) error
- func (n *TreeNodeInstance) RegisterChannelLength(c interface{}, length int) error
- func (n *TreeNodeInstance) RegisterChannels(channels ...interface{}) error
- func (n *TreeNodeInstance) RegisterChannelsLength(length int, channels ...interface{}) error
- func (n *TreeNodeInstance) RegisterHandler(c interface{}) error
- func (n *TreeNodeInstance) RegisterHandlers(handlers ...interface{}) error
- func (n *TreeNodeInstance) Root() *TreeNode
- func (n *TreeNodeInstance) Roster() *Roster
- func (n *TreeNodeInstance) Rx() uint64
- func (n *TreeNodeInstance) SendTo(to *TreeNode, msg interface{}) error
- func (n *TreeNodeInstance) SendToChildren(msg interface{}) error
- func (n *TreeNodeInstance) SendToChildrenInParallel(msg interface{}) []error
- func (n *TreeNodeInstance) SendToParent(msg interface{}) error
- func (n *TreeNodeInstance) ServerIdentity() *network.ServerIdentity
- func (n *TreeNodeInstance) SetConfig(c *GenericConfig) error
- func (n *TreeNodeInstance) Shutdown() error
- func (n *TreeNodeInstance) Suite() network.Suite
- func (n *TreeNodeInstance) Token() *Token
- func (n *TreeNodeInstance) TokenID() TokenID
- func (n *TreeNodeInstance) Tree() *Tree
- func (n *TreeNodeInstance) TreeNode() *TreeNode
- func (n *TreeNodeInstance) TreeNodeInstance() *TreeNodeInstance
- func (n *TreeNodeInstance) Tx() uint64
- type WebSocket
Constants ¶
const ( // TCP represents the TCP mode of networking for this local test TCP = "tcp" // Local represents the Local mode of networking for this local test Local = "local" )
const ( // AggregateMessages (if set) tells to aggregate messages from all children // before sending to the (parent) Node AggregateMessages = 1 // DefaultChannelLength is the default number of messages that can wait // in a channel. DefaultChannelLength = 100 )
const SimulationFileName = "simulation.bin"
SimulationFileName is the name of the (binary encoded) file containing the simulation config.
Variables ¶
var ConfigMsgID = network.RegisterMessage(ConfigMsg{})
ConfigMsgID of the generic config message
var ErrProtocolRegistered = xerrors.New("a ProtocolInstance already has been registered using this TreeNodeInstance")
ErrProtocolRegistered is when the protocolinstance is already registered to the overlay
var ErrWrongTreeNodeInstance = xerrors.New("This TreeNodeInstance doesn't exist")
ErrWrongTreeNodeInstance is returned when you already binded a TNI with a PI.
var NilServiceID = ServiceID(uuid.Nil)
NilServiceID is the empty ServiceID
var ProtocolMsgID = network.RegisterMessage(ProtocolMsg{})
ProtocolMsgID is to be embedded in every message that is made for a ID of ProtocolMsg message as registered in network
var RequestRosterMsgID = network.RegisterMessage(RequestRoster{})
RequestRosterMsgID of RequestRoster message as registered in network Deprecated: only the tree is sent, not anymore the roster
var RequestTreeMsgID = network.RegisterMessage(RequestTree{})
RequestTreeMsgID of RequestTree message as registered in network
var ResponseTreeMsgID = network.RegisterMessage(ResponseTree{})
ResponseTreeMsgID of TreeMarshal message as registered in network
var RosterTypeID = network.RegisterMessage(Roster{})
RosterTypeID of Roster message as registered in network
var SendRosterMsgID = RosterTypeID
SendRosterMsgID of Roster message as registered in network Deprecated: only the tree is sent, not anymore the roster
var SendTreeMsgID = TreeMarshalTypeID
SendTreeMsgID of TreeMarshal message as registered in network Deprecated: use ResponseTreeMsgID
var ServiceFactory = serviceFactory{ // contains filtered or unexported fields }
ServiceFactory is the global service factory to instantiate Services
var TreeMarshalTypeID = network.RegisterMessage(TreeMarshal{})
TreeMarshalTypeID of TreeMarshal message as registered in network
Functions ¶
func InformAllServersStopped ¶
func InformAllServersStopped()
InformAllServersStopped allows to set the 'serverStarted' flag to false.
func InformServerStarted ¶
func InformServerStarted()
InformServerStarted allows to set the 'serverStarted' flag to true.
func NewPrivIdentity ¶
func NewPrivIdentity(suite network.Suite, port int) (kyber.Scalar, *network.ServerIdentity)
NewPrivIdentity returns a secret + ServerIdentity. The SI will have "localserver:+port as first address.
func ReadTomlConfig ¶
ReadTomlConfig read any structure from a toml-file Takes a filename and an optional directory-name
func RegisterMessageProxy ¶
func RegisterMessageProxy(n NewMessageProxy)
RegisterMessageProxy saves a new NewMessageProxy under its name. When a Server is instantiated, all MessageProxys will be generated and stored for this Server.
func SimulationRegister ¶
func SimulationRegister(name string, sim simulationCreate)
SimulationRegister is must to be called to register a simulation. Protocol or simulation developers must not forget to call this function with the protocol's name.
func UnregisterService ¶
UnregisterService removes a service from the global pool.
func WriteTomlConfig ¶
WriteTomlConfig write any structure to a toml-file Takes a filename and an optional directory-name.
Types ¶
type BidirectionalStreamer ¶
type BidirectionalStreamer interface { // ProcessClientStreamRequest is different from ProcessClientRequest in that // it takes a chanel of inputs and watches for additional inputs. Additional // inputs are then forwarded to the service. ProcessClientStreamRequest(req *http.Request, path string, clientInputs chan []byte) (chan []byte, error) // IsStreaming checks if the handler registered at the given path is a // streaming handler or not. It returns an error in the case the handler is // not found. IsStreaming(path string) (bool, error) }
BidirectionalStreamer specifies the functions needed to handle a bi-directional streamer, where the client is able to use the same chanel in order to send multiple requests.
type CertificateReloader ¶
CertificateReloader takes care of reloading a TLS certificate when requested.
func NewCertificateReloader ¶
func NewCertificateReloader(certPath, keyPath string) (*CertificateReloader, error)
NewCertificateReloader takes two file paths as parameter that contain the certificate and the key data to create an automatic reloader. It will try to read again the files when the certificate is almost expired.
func (*CertificateReloader) GetCertificateFunc ¶
func (cr *CertificateReloader) GetCertificateFunc() func(*tls.ClientHelloInfo) (*tls.Certificate, error)
GetCertificateFunc makes a function that can be passed to the TLSConfig so that it resolves the most up-to-date one.
type Client ¶
type Client struct { // if not nil, use TLS TLSClientConfig *tls.Config // How long to wait for a reply ReadTimeout time.Duration // How long to wait to open a connection HandshakeTimeout time.Duration sync.Mutex // contains filtered or unexported fields }
Client is a struct used to communicate with a remote Service running on a onet.Server. Using Send it can connect to multiple remote Servers.
func NewClient ¶
NewClient returns a client using the service s. On the first Send, the connection will be started, until Close is called.
func NewClientKeep ¶
NewClientKeep returns a Client that doesn't close the connection between two messages if it's the same server.
func (*Client) Close ¶
Close sends a close-command to all open connections and returns nil if no errors occurred or all errors encountered concatenated together as a string.
func (*Client) Rx ¶
Rx returns the number of bytes read by this Client. It implements the monitor.CounterIOMeasure interface.
func (*Client) Send ¶
Send will marshal the message into a ClientRequest message and send it. It has a very simple parallel sending mechanism included: if the send goes to a new or an idle connection, the message is sent right away. If the current connection is busy, it waits for it to be free.
func (*Client) SendProtobuf ¶
func (c *Client) SendProtobuf(dst *network.ServerIdentity, msg interface{}, ret interface{}) error
SendProtobuf wraps protobuf.(En|De)code over the Client.Send-function. It takes the destination, a pointer to a msg-structure that will be protobuf-encoded and sent over the websocket. If ret is non-nil, it has to be a pointer to the struct that is sent back to the client. If there is no error, the ret-structure is filled with the data from the service.
func (*Client) SendProtobufParallel ¶
func (c *Client) SendProtobufParallel(nodes []*network.ServerIdentity, msg interface{}, ret interface{}, opt *ParallelOptions) (*network.ServerIdentity, error)
SendProtobufParallel sends the msg to a set of nodes in parallel and returns the first successful answer. If all nodes return an error, only the first error is returned. The behaviour of this method can be changed using the ParallelOptions argument. It is kept as a structure for future enhancements. If opt is nil, then standard values will be taken.
func (*Client) SendProtobufParallelWithDecoder ¶
func (c *Client) SendProtobufParallelWithDecoder(nodes []*network.ServerIdentity, msg interface{}, ret interface{}, opt *ParallelOptions, decoder Decoder) (*network.ServerIdentity, error)
SendProtobufParallelWithDecoder sends the msg to a set of nodes in parallel and returns the first successful answer. If all nodes return an error, only the first error is returned. The behaviour of this method can be changed using the ParallelOptions argument. It is kept as a structure for future enhancements. If opt is nil, then standard values will be taken.
func (*Client) SendToAll ¶
SendToAll sends a message to all ServerIdentities of the Roster and returns all errors encountered concatenated together as a string.
func (*Client) Stream ¶
func (c *Client) Stream(dst *network.ServerIdentity, msg interface{}) (StreamingConn, error)
Stream will send a request to start streaming, it returns a connection where the client can continue to read values from it.
type ConfigMsg ¶
type ConfigMsg struct { Config GenericConfig Dest TokenID }
ConfigMsg is sent by the overlay containing a generic slice of bytes to give to service in the `NewProtocol` method.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context represents the methods that are available to a service.
func (*Context) CreateProtocol ¶
func (c *Context) CreateProtocol(name string, t *Tree) (ProtocolInstance, error)
CreateProtocol returns a ProtocolInstance bound to the service.
func (*Context) GetAdditionalBucket ¶
GetAdditionalBucket makes sure that a bucket with the given name exists, by eventually creating it, and returns the created bucket name, which is the servicename + "_" + the given name.
This function should only be used if the Load and Save functions are not sufficient. Additionally, the user should not create buckets directly on the DB but always call this function to create new buckets to avoid bucket name conflicts.
func (*Context) GetValidPeers ¶
func (c *Context) GetValidPeers(peerID network.PeerSetID) []network. ServerIdentityID
GetValidPeers returns the set of peers with which the server underlying this context can communicate. The return value is `nil` in case the set of valid peers has not yet been initialized, meaning that all peers are valid.
func (*Context) Load ¶
Load takes a key and returns the network.Unmarshaled data. Returns a nil value if the key does not exist.
func (*Context) LoadRaw ¶
LoadRaw takes a key and returns the raw, unmarshalled data. Returns a nil value if the key does not exist.
func (*Context) LoadVersion ¶
LoadVersion returns the version of the database, or 0 if no version has been found.
func (*Context) NewPeerSetID ¶
NewPeerSetID creates a new PeerSetID identifying a subset of valid peers. This is to be used by services, providing their own specific identifier, e.g. the SkipChainID for ByzCoin.
func (*Context) NewTreeNodeInstance ¶
func (c *Context) NewTreeNodeInstance(t *Tree, tn *TreeNode, protoName string) *TreeNodeInstance
NewTreeNodeInstance creates a TreeNodeInstance that is bound to a service instead of the Overlay.
func (*Context) ProtocolRegister ¶
func (c *Context) ProtocolRegister(name string, protocol NewProtocol) (ProtocolID, error)
ProtocolRegister signs up a new protocol to this Server. Contrary go GlobalProtocolRegister, the protocol registered here is tied to that server. This is useful for simulations where more than one Server exists in the global namespace. It returns the ID of the protocol.
func (*Context) RegisterMessageProxy ¶
func (c *Context) RegisterMessageProxy(m MessageProxy)
RegisterMessageProxy registers a message proxy only for this server / overlay
func (*Context) RegisterProcessor ¶
func (c *Context) RegisterProcessor(p network.Processor, msgType network.MessageTypeID)
RegisterProcessor overrides the RegisterProcessor methods of the Dispatcher. It delegates the dispatching to the serviceManager.
func (*Context) RegisterProcessorFunc ¶
func (c *Context) RegisterProcessorFunc(msgType network.MessageTypeID, fn func(*network.Envelope) error)
RegisterProcessorFunc takes a message-type and a function that will be called if this message-type is received.
func (*Context) RegisterProtocolInstance ¶
func (c *Context) RegisterProtocolInstance(pi ProtocolInstance) error
RegisterProtocolInstance registers a new instance of a protocol using overlay.
func (*Context) RegisterStatusReporter ¶
func (c *Context) RegisterStatusReporter(name string, s StatusReporter)
RegisterStatusReporter registers a new StatusReporter.
func (*Context) ReportStatus ¶
ReportStatus returns all status of the services.
func (*Context) Save ¶
Save takes a key and an interface. The interface will be network.Marshal'ed and saved in the database under the bucket named after the service name.
The data will be stored in a different bucket for every service.
func (*Context) SaveVersion ¶
SaveVersion stores the given version as the current database version.
func (*Context) SendRaw ¶
func (c *Context) SendRaw(si *network.ServerIdentity, msg interface{}) error
SendRaw sends a message to the ServerIdentity.
func (*Context) ServerIdentity ¶
func (c *Context) ServerIdentity() *network.ServerIdentity
ServerIdentity returns this server's identity.
func (*Context) SetValidPeers ¶
func (c *Context) SetValidPeers(peerID network.PeerSetID, peers []*network.ServerIdentity)
SetValidPeers sets the set of peers with which the server underlying this context can communicate.
type ContextDB ¶
type ContextDB interface { Load(key []byte) (interface{}, error) LoadRaw(key []byte) ([]byte, error) LoadVersion() (int, error) SaveVersion(version int) error }
The ContextDB interface allows for easy testing in the services.
type Decoder ¶
Decoder is a function that takes the data and the interface to fill in as input and decodes the message.
type GenericConfig ¶
type GenericConfig struct {
Data []byte
}
GenericConfig is a config that can hold any type of specific configs for protocols. It is passed down to the service NewProtocol function.
type LeakyTestCheck ¶
type LeakyTestCheck int
LeakyTestCheck represents an enum to indicate how deep CloseAll needs to check the tests.
const ( // CheckNone will make CloseAll not check anything. CheckNone LeakyTestCheck = iota + 1 // CheckGoroutines will only check for leaking goroutines. CheckGoroutines // CheckAll will also check for leaking Overlay.Processors and // ProtocolInstances. CheckAll )
type LocalTest ¶
type LocalTest struct { // A map of ServerIdentity.Id to Servers Servers map[network.ServerIdentityID]*Server // A map of ServerIdentity.Id to Overlays Overlays map[network.ServerIdentityID]*Overlay // A map of ServerIdentity.Id to Services Services map[network.ServerIdentityID]map[ServiceID]Service // A map of Tree.Id to Trees Trees map[TreeID]*Tree // All single nodes Nodes []*TreeNodeInstance // How carefully to check for leaking resources at the end of the test. Check LeakyTestCheck Suite network.Suite T *testing.T // contains filtered or unexported fields }
LocalTest represents all that is needed for a local test-run
func NewLocalTest ¶
NewLocalTest creates a new Local handler that can be used to test protocols locally
func NewLocalTestT ¶
NewLocalTestT is like NewLocalTest but also stores the testing.T variable.
func NewTCPTest ¶
NewTCPTest returns a LocalTest but using a TCPRouter as the underlying communication layer.
func NewTCPTestWithTLS ¶
func NewTCPTestWithTLS(s network.Suite, wsTLSCertificate []byte, wsTLSCertificateKey []byte) *LocalTest
NewTCPTestWithTLS returns a LocalTest but using a TCPRouter as the underlying communication layer and containing information for TLS setup.
func (*LocalTest) CreateProtocol ¶
func (l *LocalTest) CreateProtocol(name string, t *Tree) (ProtocolInstance, error)
CreateProtocol takes a name and a tree and will create a new Node with the protocol 'name' without running it
func (*LocalTest) GenBigTree ¶
func (l *LocalTest) GenBigTree(nbrTreeNodes, nbrServers, bf int, register bool) ([]*Server, *Roster, *Tree)
GenBigTree will create a tree of n servers. If register is true, the Roster and Tree will be registered with the overlay. 'nbrServers' is how many servers are created 'nbrTreeNodes' is how many TreeNodes are created nbrServers can be smaller than nbrTreeNodes, in which case a given server will be used more than once in the tree.
func (*LocalTest) GenRosterFromHost ¶
GenRosterFromHost takes a number of servers as arguments and creates an Roster.
func (*LocalTest) GenServers ¶
GenServers returns n Servers with a localRouter
func (*LocalTest) GenTree ¶
GenTree will create a tree of n servers with a localRouter, and returns the list of servers and the associated roster / tree.
func (*LocalTest) GetPrivate ¶
GetPrivate returns the private key of a server
func (*LocalTest) GetServices ¶
GetServices returns a slice of all services asked for. The sid is the id of the service that will be collected.
func (*LocalTest) GetTreeNodeInstances ¶
func (l *LocalTest) GetTreeNodeInstances(id network.ServerIdentityID) []*TreeNodeInstance
GetTreeNodeInstances returns all TreeNodeInstances that belong to a server
func (*LocalTest) MakeSRS ¶
MakeSRS creates and returns nbr Servers, the associated Roster and the Service object of the first server in the list having sid as a ServiceID.
func (*LocalTest) NewClient ¶
NewClient returns *Client for which the types depend on the mode of the LocalContext.
func (*LocalTest) NewClientKeep ¶
NewClientKeep returns *Client for which the types depend on the mode of the LocalContext, the connection is not closed after sending requests.
func (*LocalTest) NewLocalServer ¶
NewLocalServer returns a fresh Host using local connections within the context of this LocalTest
func (*LocalTest) NewServer ¶
NewServer returns a new server which type is determined by the local mode: TCP or Local. If it's TCP, then an available port is used, otherwise, the port given in argument is used.
func (*LocalTest) NewTreeNodeInstance ¶
func (l *LocalTest) NewTreeNodeInstance(tn *TreeNode, protName string) (*TreeNodeInstance, error)
NewTreeNodeInstance creates a new node on a TreeNode
func (*LocalTest) StartProtocol ¶
func (l *LocalTest) StartProtocol(name string, t *Tree) (ProtocolInstance, error)
StartProtocol takes a name and a tree and will create a new Node with the protocol 'name' running from the tree-root
type MessageProxy ¶
type MessageProxy interface { // Wrap takes a message and the overlay information and returns the message // that has to be sent directly to the network alongside with any error that // happened. // If msg is nil, it is only an internal message of the Overlay. Wrap(msg interface{}, info *OverlayMsg) (interface{}, error) // Unwrap takes the message coming from the network and returns the // inner message that is going to be dispatched to the ProtocolInstance, the // OverlayMessage needed by the Overlay to function correctly and then any // error that might have occurred. Unwrap(msg interface{}) (interface{}, *OverlayMsg, error) // PacketType returns the packet type ID that this Protocol expects from the // network. This is needed in order for the Overlay to receive those // messages and dispatch them to the correct MessageProxy. PacketType() network.MessageTypeID // Name returns the name associated with this MessageProxy. When creating a // protocol, if one use a name used by a MessageProxy, this MessageProxy will be // used to Wrap and Unwrap messages. Name() string }
MessageProxy is an interface that allows one protocol to completely define its wire protocol format while still using the Overlay. Cothority sends different messages dynamically as slices of bytes, whereas Google proposes to use union-types: https://developers.google.com/protocol-buffers/docs/techniques#union This is a wrapper to enable union-types while still keeping compatibility with the dynamic cothority-messages. Implementations must provide methods to pass from the 'union-types' to 'cothority-dynamic-messages' with the Wrap and Unwrap method. A default one is provided with defaultMessageProxy so the regular wire-format protocol can still be used.
type MsgHandler ¶
type MsgHandler func([]*interface{})
MsgHandler is called upon reception of a certain message-type
type NewMessageProxy ¶
type NewMessageProxy func() MessageProxy
NewMessageProxy is a function typedef to instantiate a new MessageProxy.
type NewProtocol ¶
type NewProtocol func(*TreeNodeInstance) (ProtocolInstance, error)
NewProtocol is the function-signature needed to instantiate a new protocol
type NewServiceFunc ¶
NewServiceFunc is the type of a function that is used to instantiate a given Service A service is initialized with a Server (to send messages to someone).
type Overlay ¶
type Overlay struct {
// contains filtered or unexported fields
}
Overlay keeps all trees and entity-lists for a given Server. It creates Nodes and ProtocolInstances upon request and dispatches the messages.
func (*Overlay) Close ¶
func (o *Overlay) Close()
Close calls all nodes, deletes them from the list and closes them
func (*Overlay) CreateProtocol ¶
CreateProtocol creates a ProtocolInstance, registers it to the Overlay. Additionally, if sid is different than NilServiceID, sid is added to the token so the protocol will be picked up by the correct service and handled by its NewProtocol method. If the sid is NilServiceID, then the protocol is handled by onet alone.
func (*Overlay) NewTreeNodeInstanceFromProtoName ¶
func (o *Overlay) NewTreeNodeInstanceFromProtoName(t *Tree, name string) *TreeNodeInstance
NewTreeNodeInstanceFromProtoName takes a protocol name and a tree and instantiate a TreeNodeInstance for this protocol.
func (*Overlay) NewTreeNodeInstanceFromProtocol ¶
func (o *Overlay) NewTreeNodeInstanceFromProtocol(t *Tree, tn *TreeNode, protoID ProtocolID, io MessageProxy) *TreeNodeInstance
NewTreeNodeInstanceFromProtocol takes a tree and a treenode (normally the root) and and protocolID and returns a fresh TreeNodeInstance.
func (*Overlay) NewTreeNodeInstanceFromService ¶
func (o *Overlay) NewTreeNodeInstanceFromService(t *Tree, tn *TreeNode, protoID ProtocolID, servID ServiceID, io MessageProxy) *TreeNodeInstance
NewTreeNodeInstanceFromService takes a tree, a TreeNode and a service ID and returns a TNI.
func (*Overlay) Process ¶
Process implements the Processor interface so it process the messages that it wants.
func (*Overlay) RegisterMessageProxy ¶
func (o *Overlay) RegisterMessageProxy(m MessageProxy)
RegisterMessageProxy registers a message proxy only for this overlay
func (*Overlay) RegisterProtocolInstance ¶
func (o *Overlay) RegisterProtocolInstance(pi ProtocolInstance) error
RegisterProtocolInstance takes a PI and stores it for dispatching the message to it.
func (*Overlay) RegisterTree ¶
RegisterTree takes a tree and puts it in the map
func (*Overlay) SendToTreeNode ¶
func (o *Overlay) SendToTreeNode(from *Token, to *TreeNode, msg network.Message, io MessageProxy, c *GenericConfig) (uint64, error)
SendToTreeNode sends a message to a treeNode from is the sender token to is the treenode of the destination msg is the message to send io is the messageproxy used to correctly create the wire format c is the generic config that should be sent beforehand in order to get passed in the `NewProtocol` method if a Service has created the protocol and set the config with `SetConfig`. It can be nil.
func (*Overlay) ServerIdentity ¶
func (o *Overlay) ServerIdentity() *network.ServerIdentity
ServerIdentity Returns the entity of the Host
func (*Overlay) StartProtocol ¶
StartProtocol will create and start a ProtocolInstance.
func (*Overlay) TransmitMsg ¶
func (o *Overlay) TransmitMsg(onetMsg *ProtocolMsg, io MessageProxy) error
TransmitMsg takes a message received from the host and treats it. It might - ask for the identityList - ask for the Tree - create a new protocolInstance - pass it to a given protocolInstance io is the messageProxy to use if a specific wireformat protocol is used. It can be nil: in that case it falls back to the default wire protocol.
func (*Overlay) TreeNodeFromToken ¶
TreeNodeFromToken returns the treeNode corresponding to a token Deprecated: only the overlay should create treeNodes but use TreeNodeFromTree if you need to create one treeNode
func (*Overlay) TreeNodeFromTree ¶
func (o *Overlay) TreeNodeFromTree(tree *Tree, id TreeNodeID) (*TreeNode, error)
TreeNodeFromTree returns the treeNode corresponding to the id
type OverlayMsg ¶
type OverlayMsg struct { TreeNodeInfo *TreeNodeInfo // Deprecated: roster is not sent/requested anymore, only the tree RequestRoster *RequestRoster // Deprecated: roster is not sent/requested anymore, only the tree Roster *Roster RequestTree *RequestTree ResponseTree *ResponseTree // Deprecated: use ResponseTree to send the tree and the roster TreeMarshal *TreeMarshal Config *GenericConfig }
OverlayMsg contains all routing-information about the tree and the roster.
type ParallelOptions ¶
type ParallelOptions struct { // Parallel indicates how many requests are sent in parallel. // Default: half of all nodes in the roster Parallel int // AskNodes indicates how many requests are sent in total. // Default: all nodes in the roster, except if StartNodes is set > 0 AskNodes int // StartNode indicates where to start in the roster. If StartNode is > 0 and < len(roster), // but AskNodes is 0, then AskNodes will be set to len(Roster)-StartNode. // Default: 0 StartNode int // QuitError - if true, the first error received will be returned. // Default: false QuitError bool // IgnoreNodes is a set of nodes that will not be contacted. They are counted towards // AskNodes and StartNode, but not contacted. // Default: false IgnoreNodes []*network.ServerIdentity // DontShuffle - if true, the nodes will be contacted in the same order as given in the Roster. // StartNode will be applied before shuffling. // Default: false DontShuffle bool }
ParallelOptions defines how SendProtobufParallel behaves. Each field has a default value that will be used if 'nil' is passed to SendProtobufParallel. For integers, the default will also be used if the integer = 0.
func (*ParallelOptions) GetList ¶
func (po *ParallelOptions) GetList(nodes []*network.ServerIdentity) (parallel int, nodesChan chan *network.ServerIdentity)
GetList returns how many requests to start in parallel and a channel of nodes to be used. If po == nil, it uses default values.
func (*ParallelOptions) Quit ¶
func (po *ParallelOptions) Quit() bool
Quit return false if po == nil, or the value in po.QuitError.
type ProtocolID ¶
ProtocolID uniquely identifies a protocol
func GlobalProtocolRegister ¶
func GlobalProtocolRegister(name string, protocol NewProtocol) (ProtocolID, error)
GlobalProtocolRegister registers a protocol in the global namespace. This is used in protocols that register themselves in the `init`-method. All registered protocols will be copied to every instantiated Server. If a protocol is tied to a service, use `Server.ProtocolRegisterName`
func ProtocolNameToID ¶
func ProtocolNameToID(name string) ProtocolID
ProtocolNameToID returns the ProtocolID corresponding to the given name.
func (ProtocolID) Equal ¶
func (pid ProtocolID) Equal(pid2 ProtocolID) bool
Equal returns true if and only if pid2 equals this ProtocolID.
func (ProtocolID) IsNil ¶
func (pid ProtocolID) IsNil() bool
IsNil returns true iff the ProtocolID is Nil
func (ProtocolID) String ¶
func (pid ProtocolID) String() string
String returns canonical string representation of the ID
type ProtocolInstance ¶
type ProtocolInstance interface { // Start is called when a leader has created its tree configuration and // wants to start a protocol, it calls host.StartProtocol(protocolID), that // in turn instantiates a new protocol (with a fresh token), and then calls // Start on it. Start() error // Dispatch is called at the beginning by onet for listening on the channels Dispatch() error // ProcessProtocolMsg is a method that is called each time a message // arrives for this protocolInstance. TreeNodeInstance implements that // method for you using channels or handlers. ProcessProtocolMsg(*ProtocolMsg) // The token representing this ProtocolInstance Token() *Token // Shutdown cleans up the resources used by this protocol instance Shutdown() error }
ProtocolInstance is the interface that instances have to use in order to be recognized as protocols
type ProtocolMsg ¶
type ProtocolMsg struct { // Token uniquely identify the protocol instance this msg is made for From *Token // The TreeNodeId Where the message goes to To *Token // NOTE: this is taken from network.NetworkMessage ServerIdentity *network.ServerIdentity // MsgType of the underlying data MsgType network.MessageTypeID // The interface to the actual Data Msg network.Message // The actual data as binary blob MsgSlice []byte // The size of the data Size network.Size // Config is the config passed to the protocol constructor. Config *GenericConfig }
ProtocolMsg is to be embedded in every message that is made for a ProtocolInstance
type RequestRoster ¶
type RequestRoster struct {
RosterID RosterID
}
RequestRoster is used to ask the parent for a given Roster
type RequestTree ¶
type RequestTree struct { // The treeID of the tree we want TreeID TreeID // Version of the request tree Version uint32 }
RequestTree is used to ask the parent for a given Tree
type ResponseTree ¶
type ResponseTree struct { TreeMarshal *TreeMarshal Roster *Roster }
ResponseTree contains the information to build a tree
type Roster ¶
type Roster struct { // Deprecated: ID can be generated using the list of server identities. Use GetID instead. ID RosterID // List is the list of actual entities. List []*network.ServerIdentity Aggregate kyber.Point }
A Roster is a list of ServerIdentity we choose to run some tree on it ( and therefor some protocols). Access is not safe from multiple goroutines.
func NewRoster ¶
func NewRoster(ids []*network.ServerIdentity) *Roster
NewRoster creates a new roster from a list of entities. It also adds a UUID which is randomly chosen.
func (*Roster) Concat ¶
func (ro *Roster) Concat(sis ...*network.ServerIdentity) *Roster
Concat makes a new roster using an existing one and a list of server identities while preserving the order of the roster by appending at the end
func (*Roster) Contains ¶
Contains checks if the roster contains the given array of public keys and no more
func (*Roster) GenerateBigNaryTree ¶
GenerateBigNaryTree creates a tree where each node has N children. It will make a tree with exactly 'nodes' elements, regardless of the size of the Roster. If 'nodes' is bigger than the number of elements in the Roster, it will add some or all elements in the Roster more than once. If the length of the Roster is equal to 'nodes', it is guaranteed that all ServerIdentities from the Roster will be used in the tree. However, for some configurations it is impossible to use all ServerIdentities from the Roster and still avoid having a parent and a child from the same host. In this case use-all has preference over not-the-same-host.
func (*Roster) GenerateBinaryTree ¶
GenerateBinaryTree creates a binary tree out of the Roster out of it. The first element of the Roster will be the root element.
func (*Roster) GenerateNaryTree ¶
GenerateNaryTree creates a tree where each node has N children. The first element of the Roster will be the root element.
func (*Roster) GenerateNaryTreeWithRoot ¶
func (ro *Roster) GenerateNaryTreeWithRoot(N int, root *network.ServerIdentity) *Tree
GenerateNaryTreeWithRoot creates a tree where each node has N children. The root is given as an ServerIdentity. If root doesn't exist in the roster, `nil` will be returned. The generation of the tree is done in a simple for-loop, so that the original roster can be used for tree creation, even if the root is not at position 0. If root == nil, the first element of the roster will be taken as root.
If you need the root node to be at the first position of the roster, then you need to create a new roster using roster.NewRosterWithRoot. Else this method does not change the underlying roster or create a new one.
func (*Roster) GenerateStar ¶
GenerateStar creates a star topology with the first element of Roster as root, and all other elements as children of the root.
func (*Roster) Get ¶
func (ro *Roster) Get(idx int) *network.ServerIdentity
Get simply returns the entity that is stored at that index in the entitylist returns nil if index error
func (Roster) IsRotation ¶
IsRotation returns true if the target is a rotated (the same roster but with shifted server identities) version of the receiver.
func (*Roster) NewRosterWithRoot ¶
func (ro *Roster) NewRosterWithRoot(root *network.ServerIdentity) *Roster
NewRosterWithRoot returns a copy of the roster but with the given ServerIdentity at the first entry in the roster.
func (*Roster) Publics ¶
func (ro *Roster) Publics() []kyber.Point
Publics returns the public-keys of the underlying Roster. It won't modify the underlying list.
func (*Roster) RandomServerIdentity ¶
func (ro *Roster) RandomServerIdentity() *network.ServerIdentity
RandomServerIdentity returns a random element of the Roster.
func (*Roster) RandomSubset ¶
func (ro *Roster) RandomSubset(root *network.ServerIdentity, n int) *Roster
RandomSubset returns a new Roster which starts with root and is followed by a random subset of n elements of ro, not including root.
func (*Roster) Search ¶
func (ro *Roster) Search(eID network.ServerIdentityID) (int, *network.ServerIdentity)
Search searches the Roster for the given ServerIdentityID and returns the corresponding ServerIdentity.
func (Roster) ServiceAggregate ¶
ServiceAggregate returns the sum of all public keys of a given service. This is often used as the aggregate public key. If one or more of the service public keys are not present, it will return an error.
func (*Roster) ServicePublics ¶
ServicePublics returns the list of public keys for a specific service. If it is registered with a different key pair, it will return the associated one and the default key in the contrary
type RosterID ¶
RosterID uniquely identifies an Roster
type RosterToml ¶
type RosterToml struct { ID RosterID List []*network.ServerIdentityToml }
RosterToml is the struct can can embedded ServerIdentityToml to be written in a toml file
type RosterUnknown ¶
type RosterUnknown struct { }
RosterUnknown is used in case the entity list is unknown
type RoundID ¶
RoundID uniquely identifies a round of a protocol run
type Server ¶
type Server struct { *network.Router // webservice WebSocket *WebSocket IsStarted bool // contains filtered or unexported fields }
Server connects the Router, the Overlay, and the Services together. It sets up everything and returns once a working network has been set up.
func NewLocalServer ¶
NewLocalServer returns a new server using a LocalRouter (channels) to communicate. At the return of this function, the router is already Run()ing in a go routine.
func NewServerTCP ¶
func NewServerTCP(e *network.ServerIdentity, suite network.Suite) *Server
NewServerTCP returns a new Server out of a private-key and its related public key within the ServerIdentity. The server will use a default TcpRouter as Router.
func NewServerTCPWithListenAddr ¶
func NewServerTCPWithListenAddr(e *network.ServerIdentity, suite network.Suite, listenAddr string) *Server
NewServerTCPWithListenAddr returns a new Server out of a private-key and its related public key within the ServerIdentity. The server will use a TcpRouter listening on the given address as Router.
func (*Server) GetService ¶
GetService is kept for backward-compatibility.
func (*Server) ProtocolRegister ¶
func (c *Server) ProtocolRegister(name string, protocol NewProtocol) (ProtocolID, error)
ProtocolRegister will sign up a new protocol to this Server. It returns the ID of the protocol.
func (*Server) Start ¶
func (c *Server) Start()
Start makes the router and the WebSocket listen on their respective ports. It returns once all servers are started.
func (*Server) StartInBackground ¶
func (c *Server) StartInBackground()
StartInBackground starts the services and returns once everything is up and running.
func (*Server) Suite ¶
Suite can (and should) be used to get the underlying Suite. Currently the suite is hardcoded into the network library. Don't use network.Suite but Host's Suite function instead if possible.
func (*Server) WaitStartup ¶
func (c *Server) WaitStartup()
WaitStartup can be called to ensure that the server is up and running. It will loop and wait 50 milliseconds between each test.
type Service ¶
type Service interface { // NewProtocol is called upon a ProtocolInstance's first message when Onet needs // to instantiate the protocol. A Service is expected to manually create // the ProtocolInstance it is using. If a Service returns (nil,nil), that // means this Service lets Onet handle the protocol instance. NewProtocol(*TreeNodeInstance, *GenericConfig) (ProtocolInstance, error) // ProcessClientRequest is called when a message from an external // client is received by the websocket for this service. The message is // forwarded to the corresponding handler keyed by the path. If the // handler is a normal one, i.e., a request-response handler, it // returns a message in the first return value and the second // (StreamingTunnel) will be set to nil. If the handler is a streaming // handler, the first return value is set to nil but the second // (StreamingTunnel) will exist. It should be used to stream messages // to the client. See the StreamingTunnel documentation on how it // should be used. The returned error will be formatted as a websocket // error code 4000, using the string form of the error as the message. ProcessClientRequest(req *http.Request, handler string, msg []byte) (reply []byte, tunnel *StreamingTunnel, err error) // Processor makes a Service being able to handle any kind of packets // directly from the network. It is used for inter service communications, // which are mostly single packets with no or little interactions needed. If // a complex logic is used for these messages, it's best to put that logic // into a ProtocolInstance that the Service will launch, since there's nicer // utilities for ProtocolInstance. network.Processor }
Service is a generic interface to define any type of services. A Service has multiple roles:
- Processing websocket client requests with ProcessClientRequests
- Handling onet information to ProtocolInstances created with NewProtocol
- Handling any kind of messages between Services between different hosts with the Processor interface
type ServiceID ¶
ServiceID is a type to represent a uuid for a Service
func RegisterNewService ¶
func RegisterNewService(name string, fn NewServiceFunc) (ServiceID, error)
RegisterNewService is a wrapper around service factory to register a service with the default suite
func RegisterNewServiceWithSuite ¶
func RegisterNewServiceWithSuite(name string, suite suites.Suite, fn NewServiceFunc) (ServiceID, error)
RegisterNewServiceWithSuite is wrapper around service factory to register a service with a given suite
type ServiceProcessor ¶
type ServiceProcessor struct { *Context // contains filtered or unexported fields }
ServiceProcessor allows for an easy integration of external messages into the Services. You have to embed it into your Service-struct as a pointer. It will process client requests that have been registered with RegisterMessage.
func NewServiceProcessor ¶
func NewServiceProcessor(c *Context) *ServiceProcessor
NewServiceProcessor initializes your ServiceProcessor.
func (*ServiceProcessor) IsStreaming ¶
func (p *ServiceProcessor) IsStreaming(path string) (bool, error)
IsStreaming tell if the service registered at the given path is a streaming service or not. Return an error if the service is not registered.
func (*ServiceProcessor) NewProtocol ¶
func (p *ServiceProcessor) NewProtocol(tn *TreeNodeInstance, conf *GenericConfig) (ProtocolInstance, error)
NewProtocol is a stub for services that don't want to intervene in the protocol-handling.
func (*ServiceProcessor) Process ¶
func (p *ServiceProcessor) Process(env *network.Envelope)
Process implements the Processor interface and dispatches ClientRequest messages.
func (*ServiceProcessor) ProcessClientRequest ¶
func (p *ServiceProcessor) ProcessClientRequest(req *http.Request, path string, buf []byte) ([]byte, *StreamingTunnel, error)
ProcessClientRequest implements the Service interface, see the interface documentation.
func (*ServiceProcessor) ProcessClientStreamRequest ¶
func (p *ServiceProcessor) ProcessClientStreamRequest(req *http.Request, path string, clientInputs chan []byte) (chan []byte, error)
ProcessClientStreamRequest allows clients to push multiple messages asynchronously to the same service handler with the same connection. Unlike in ProcessClientRequest, we take a channel of inputs that can be filled and will subsequently call the service with any new messages received in the channel. The caller is responsible for closing the client input channel when it is done.
func (*ServiceProcessor) RegisterHandler ¶
func (p *ServiceProcessor) RegisterHandler(f interface{}) error
RegisterHandler will store the given handler that will be used by the service. WebSocket will then forward requests to "ws://service_name/struct_name" to the given function f, which must be in the following form: func(msg interface{})(ret interface{}, err error)
- msg is a pointer to a structure to the message sent.
- ret is a pointer to a struct of the return-message.
- err is an error, it can be nil, or any type that implements error.
struct_name is stripped of its package-name, so a structure like network.Body will be converted to Body.
func (*ServiceProcessor) RegisterHandlers ¶
func (p *ServiceProcessor) RegisterHandlers(procs ...interface{}) error
RegisterHandlers takes a vararg of messages to register and returns the first error encountered or nil if everything was OK.
func (*ServiceProcessor) RegisterRESTHandler ¶
func (p *ServiceProcessor) RegisterRESTHandler(f interface{}, namespace, method string, minVersion, maxVersion int) error
RegisterRESTHandler takes a callback of type func(msg interface{})(ret interface{}, err error), where msg and ret must be pointers to structs. For POST and PUT, the callback is registered on the URL /v$version/$namespace/$msgStructName. The client should serialize the request using JSON and set the conent type to application/json to use the service. The response is also JSON encoded.
For GET requests, the callback is registered on the same URL. But clients can also query individual resources such as /v$version/$namespace/$msgStructName/$id. For this to work, msg in the callback must be a singleton struct with either an integer or a byte slice. For integers, the client can directly query the integer resource, for byte slices, the clients must query the hex encoded representation. Using an empty struct for msg is also supported.
The min/maxVersion argument represents the range of versions where the API is present. If breaking changes must be made then they must use a new version.
This method is experimental.
func (*ServiceProcessor) RegisterStreamingHandler ¶
func (p *ServiceProcessor) RegisterStreamingHandler(f interface{}) error
RegisterStreamingHandler stores a handler that is responsible for streaming messages to the client via a channel. Websocket will accept requests for this handler at "ws://service_name/struct_name", where struct_name is argument of f, which must be in the form: func(msg interface{})(retChan chan interface{}, closeChan chan bool, err error)
- msg is a pointer to a structure to the message sent.
- retChan is a channel of a pointer to a struct, everything sent into this channel will be forwarded to the client, if there are no more messages, the service should close retChan.
- closeChan is a boolean channel, upon receiving a message on this channel, the handler must stop sending messages and close retChan.
- err is an error, it can be nil, or any type that implements error.
struct_name is stripped of its package-name, so a structure like network.Body will be converted to Body.
func (*ServiceProcessor) RegisterStreamingHandlers ¶
func (p *ServiceProcessor) RegisterStreamingHandlers(procs ...interface{}) error
RegisterStreamingHandlers takes a vararg of messages to register and returns the first error encountered or nil if everything was OK.
type Simulation ¶
type Simulation interface { // This has to initialise all necessary files and copy them to the // 'dir'-directory. This directory will be accessible to all simulated // hosts. // Setup also gets a slice of all available hosts. In turn it has // to return a tree using one or more of these hosts. It can create // the Roster as desired, putting more than one ServerIdentity/Host on the same host. // The 'config'-argument holds all arguments read from the runfile in // toml-format. Setup(dir string, hosts []string) (*SimulationConfig, error) // Node will be run for every node and might be used to setup load- // creation. It is started once the Host is set up and running, but before // 'Run' Node(config *SimulationConfig) error // Run will begin with the simulation or return an error. It is sure // to be run on the host where 'tree.Root' is. It should only return // when all rounds are done. Run(config *SimulationConfig) error }
Simulation is an interface needed by every protocol that wants to be available to be used in a simulation.
func NewSimulation ¶
func NewSimulation(name string, conf string) (Simulation, error)
NewSimulation returns a simulation and decodes the 'conf' into the simulation-structure
type SimulationBFTree ¶
type SimulationBFTree struct { Rounds int BF int Hosts int SingleHost bool Depth int Suite string PreScript string // executable script to run before the simulation on each machine TLS bool // tells if using TLS or PlainTCP addresses }
SimulationBFTree is the main struct storing the data for all the simulations which use a tree with a certain branching factor or depth.
func (*SimulationBFTree) CreateRoster ¶
func (s *SimulationBFTree) CreateRoster(sc *SimulationConfig, addresses []string, port int)
CreateRoster creates an Roster with the host-names in 'addresses'. It creates 's.Hosts' entries, starting from 'port' for each round through 'addresses'. The network.Address(es) created are of type TLS or PlainTCP, depending on the value 'TLS' in 'sc'.
func (*SimulationBFTree) CreateTree ¶
func (s *SimulationBFTree) CreateTree(sc *SimulationConfig) error
CreateTree the tree as defined in SimulationBFTree and stores the result in 'sc'
func (*SimulationBFTree) Node ¶
func (s *SimulationBFTree) Node(sc *SimulationConfig) error
Node - standard registers the entityList and the Tree with that Overlay, so we don't have to pass that around for the experiments.
type SimulationConfig ¶
type SimulationConfig struct { // Represents the tree that has to be used Tree *Tree // The Roster used by the tree Roster *Roster // All private keys generated by 'Setup', indexed by the complete addresses PrivateKeys map[network.Address]*SimulationPrivateKey // If non-nil, points to our overlay Overlay *Overlay // If non-nil, points to our host Server *Server // Tells if the simulation should use TLS addresses; if not, use PlainTCP TLS bool // Additional configuration used to run Config string }
SimulationConfig has to be returned from 'Setup' and will be passed to 'Run'.
func LoadSimulationConfig ¶
func LoadSimulationConfig(s, dir, ca string) ([]*SimulationConfig, error)
LoadSimulationConfig gets all configuration from dir + SimulationFileName and instantiates the corresponding host 'ca'.
func (*SimulationConfig) GetService ¶
func (sc *SimulationConfig) GetService(name string) Service
GetService returns the service with the given name.
func (SimulationConfig) GetSingleHost ¶
func (sc SimulationConfig) GetSingleHost() bool
GetSingleHost returns the 'SingleHost'-flag
func (*SimulationConfig) Save ¶
func (sc *SimulationConfig) Save(dir string) error
Save takes everything in the SimulationConfig structure and saves it to dir + SimulationFileName
type SimulationConfigFile ¶
type SimulationConfigFile struct { TreeMarshal *TreeMarshal Roster *Roster PrivateKeys map[network.Address]*SimulationPrivateKey TLS bool Config string }
SimulationConfigFile stores the state of the simulation's config. Only used internally.
type SimulationPrivateKey ¶
type SimulationPrivateKey struct { Private kyber.Scalar Services []kyber.Scalar }
SimulationPrivateKey contains the default private key and the service private keys for the ones registered with a suite.
type StatusReporter ¶
type StatusReporter interface {
GetStatus() *Status
}
StatusReporter is the interface that all structures that want to return a status will implement.
type StreamingConn ¶
type StreamingConn struct {
// contains filtered or unexported fields
}
StreamingConn allows clients to read from it without sending additional requests.
func (*StreamingConn) Ping ¶ added in v3.2.9
func (c *StreamingConn) Ping(data []byte, deadline time.Time) error
Ping sends a ping message. Data can be nil.
func (*StreamingConn) ReadMessage ¶
func (c *StreamingConn) ReadMessage(ret interface{}) error
ReadMessage read more data from the connection, it will block if there are no messages.
func (*StreamingConn) ReadMessageWithOpts ¶ added in v3.2.9
func (c *StreamingConn) ReadMessageWithOpts(ret interface{}, opts StreamingReadOpts) error
ReadMessageWithOpts does the same as ReadMessage and allows to pass options.
type StreamingReadOpts ¶ added in v3.2.9
StreamingReadOpts contains options for the ReadMessageWithOpts. It allows us to add new options in the future without making breaking changes.
type StreamingTunnel ¶
type StreamingTunnel struct {
// contains filtered or unexported fields
}
StreamingTunnel is used as a tunnel between service processor and its caller, usually the websocket read-loop. When the tunnel is returned to the websocket loop, it should read from the out channel and forward the content to the client. If the client is disconnected, then the close channel should be closed. The signal exists to notify the service to stop streaming.
type TestClose ¶
type TestClose interface {
// TestClose can clean up things needed in the service.
TestClose()
}
TestClose interface allows a service to clean up for the tests. It will only be called when a test calls `LocalTest.CloseAll()`.
type Token ¶
type Token struct { RosterID RosterID TreeID TreeID // TO BE REMOVED ProtoID ProtocolID ServiceID ServiceID RoundID RoundID // TreeNodeID is defined by the TreeNodeID TreeNodeID }
A Token contains all identifiers needed to uniquely identify one protocol instance. It gets passed when a new protocol instance is created and get used by every protocol instance when they want to send a message. That way, the host knows how to create the ProtocolMsg message around the protocol's message with the right fields set.
func (*Token) ChangeTreeNodeID ¶
func (t *Token) ChangeTreeNodeID(newid TreeNodeID) *Token
ChangeTreeNodeID return a new Token containing a reference to the given TreeNode
type TokenID ¶
TokenID uniquely identifies the start and end-point of a message by an ID (see Token struct)
type Tree ¶
Tree is a topology to be used by any network layer/host layer. It contains the peer list we use, and the tree we use
func NewTree ¶
NewTree creates a new tree using the given roster and root. It also generates the id.
func NewTreeFromMarshal ¶
NewTreeFromMarshal takes a slice of bytes and an Roster to re-create the original tree
func (*Tree) BinaryMarshaler ¶
BinaryMarshaler does the same as Marshal
func (*Tree) BinaryUnmarshaler ¶
BinaryUnmarshaler takes a TreeMarshal and stores it in the tree
func (*Tree) MakeTreeMarshal ¶
func (t *Tree) MakeTreeMarshal() *TreeMarshal
MakeTreeMarshal creates a replacement-tree that is safe to send: no parent (creates loops), only sends ids (not send the roster again)
func (*Tree) Marshal ¶
Marshal creates a simple binary-representation of the tree containing only the ids of the elements. Use NewTreeFromMarshal to get back the original tree
func (*Tree) Search ¶
func (t *Tree) Search(tn TreeNodeID) (ret *TreeNode)
Search searches the Tree for the given TreeNodeID and returns the corresponding TreeNode
type TreeID ¶
TreeID uniquely identifies a Tree struct in the onet framework.
type TreeMarshal ¶
type TreeMarshal struct { // This is the UUID of the corresponding TreeNode TreeNodeID TreeNodeID // TreeId identifies the Tree for the top-node TreeID TreeID // This is the UUID of the ServerIdentity, except ServerIdentityID network.ServerIdentityID // for the top-node this contains the Roster's ID RosterID RosterID // All children from this tree. The top-node only has one child, which is // the root Children []*TreeMarshal }
TreeMarshal is used to send and receive a tree-structure without having to copy the whole nodelist
func TreeMarshalCopyTree ¶
func TreeMarshalCopyTree(tr *TreeNode) *TreeMarshal
TreeMarshalCopyTree takes a TreeNode and returns a corresponding TreeMarshal
func (TreeMarshal) MakeTree ¶
func (tm TreeMarshal) MakeTree(ro *Roster) (*Tree, error)
MakeTree creates a tree given an Roster
func (*TreeMarshal) MakeTreeFromList ¶
func (tm *TreeMarshal) MakeTreeFromList(parent *TreeNode, ro *Roster) (*TreeNode, error)
MakeTreeFromList creates a sub-tree given an Roster
func (*TreeMarshal) String ¶
func (tm *TreeMarshal) String() string
type TreeNode ¶
type TreeNode struct { // The Id represents that node of the tree ID TreeNodeID // The ServerIdentity points to the corresponding host. One given host // can be used more than once in a tree. ServerIdentity *network.ServerIdentity // RosterIndex is the index in the Roster where the `ServerIdentity` is located RosterIndex int // Parent link Parent *TreeNode // Children links Children []*TreeNode // Aggregate public key for *this* subtree,i.e. this node's public key + the // aggregate of all its children's aggregate public key PublicAggregateSubTree kyber.Point }
TreeNode is one node in the tree
func NewTreeNode ¶
func NewTreeNode(entityIdx int, ni *network.ServerIdentity) *TreeNode
NewTreeNode creates a new TreeNode with the proper Id
func (*TreeNode) AggregatePublic ¶
AggregatePublic will return the aggregate public key of the TreeNode and all it's children
func (*TreeNode) IsConnectedTo ¶
func (t *TreeNode) IsConnectedTo(si *network.ServerIdentity) bool
IsConnectedTo checks if the TreeNode can communicate with its parent or children.
func (*TreeNode) SubtreeCount ¶
SubtreeCount returns how many children are attached to that TreeNode.
type TreeNodeID ¶
TreeNodeID identifies a given TreeNode struct in the onet framework.
func (TreeNodeID) Equal ¶
func (tId TreeNodeID) Equal(tID2 TreeNodeID) bool
Equal returns true if and only if the given TreeNodeID equals tId.
func (TreeNodeID) IsNil ¶
func (tId TreeNodeID) IsNil() bool
IsNil returns true iff the TreeNodID is Nil
func (TreeNodeID) String ¶
func (tId TreeNodeID) String() string
String returns a canonical representation of the TreeNodeID.
type TreeNodeInfo ¶
TreeNodeInfo holds the sender and the destination of the message.
type TreeNodeInstance ¶
type TreeNodeInstance struct {
// contains filtered or unexported fields
}
TreeNodeInstance represents a protocol-instance in a given TreeNode. It embeds an Overlay where all the tree-structures are stored.
func (*TreeNodeInstance) Aggregate ¶
func (n *TreeNodeInstance) Aggregate() kyber.Point
Aggregate returns the sum of all public key of the roster for this TreeNodeInstance, either the specific or the default if one or more of the nodes don't have the service-public key available.
func (*TreeNodeInstance) Broadcast ¶
func (n *TreeNodeInstance) Broadcast(msg interface{}) []error
Broadcast sends a given message from the calling node directly to all other TreeNodes
func (*TreeNodeInstance) Children ¶
func (n *TreeNodeInstance) Children() []*TreeNode
Children returns the children of ourselves
func (*TreeNodeInstance) CloseHost ¶
func (n *TreeNodeInstance) CloseHost() error
CloseHost closes the underlying onet.Host (which closes the overlay and sends Shutdown to all protocol instances) NOTE: It is to be used VERY carefully and is likely to disappear in the next releases.
func (*TreeNodeInstance) CreateProtocol ¶
func (n *TreeNodeInstance) CreateProtocol(name string, t *Tree) (ProtocolInstance, error)
CreateProtocol instantiates a new protocol of name "name" and returns it with any error that might have happened during the creation. If the TreeNodeInstance calling this is attached to a service, the new protocol will also be attached to this same service. Else the new protocol will only be handled by onet.
func (*TreeNodeInstance) Dispatch ¶
func (n *TreeNodeInstance) Dispatch() error
Dispatch - the standard dispatching function is empty
func (*TreeNodeInstance) Done ¶
func (n *TreeNodeInstance) Done()
Done calls onDoneCallback if available and only finishes when the return- value is true.
func (*TreeNodeInstance) Host ¶
func (n *TreeNodeInstance) Host() *Server
Host returns the underlying Host of this node.
WARNING: you should not play with that feature unless you know what you are doing. This feature is meant to access the low level parts of the API. For example it is used to add a new tree config / new entity list to the Server.
func (*TreeNodeInstance) Index ¶
func (n *TreeNodeInstance) Index() int
Index returns the index of the node in the Roster
func (*TreeNodeInstance) Info ¶
func (n *TreeNodeInstance) Info() string
Info returns a human readable representation name of this Node (IP address and TokenID).
func (*TreeNodeInstance) IsLeaf ¶
func (n *TreeNodeInstance) IsLeaf() bool
IsLeaf returns whether whether we are at the bottom of the tree
func (*TreeNodeInstance) IsRoot ¶
func (n *TreeNodeInstance) IsRoot() bool
IsRoot returns whether whether we are at the top of the tree
func (*TreeNodeInstance) List ¶
func (n *TreeNodeInstance) List() []*TreeNode
List returns the list of TreeNodes cached in the node (creating it if necessary)
func (*TreeNodeInstance) Multicast ¶
func (n *TreeNodeInstance) Multicast(msg interface{}, nodes ...*TreeNode) []error
Multicast ... XXX: should probably have a parallel more robust version like "SendToChildrenInParallel"
func (*TreeNodeInstance) Name ¶
func (n *TreeNodeInstance) Name() string
Name returns a human readable name of this Node (IP address).
func (*TreeNodeInstance) NodePublic ¶
func (n *TreeNodeInstance) NodePublic(si *network.ServerIdentity) kyber.Point
NodePublic returns the public key associated with the node's service stored in the given server identity
func (*TreeNodeInstance) OnDoneCallback ¶
func (n *TreeNodeInstance) OnDoneCallback(fn func() bool)
OnDoneCallback should be called if we want to control the Done() of the node. It is used by protocols that uses others protocols inside and that want to control when the final Done() should be called. the function should return true if the real Done() has to be called otherwise false.
func (*TreeNodeInstance) Parent ¶
func (n *TreeNodeInstance) Parent() *TreeNode
Parent returns the parent-TreeNode of ourselves
func (*TreeNodeInstance) Private ¶
func (n *TreeNodeInstance) Private() kyber.Scalar
Private returns the private key of the service entity
func (*TreeNodeInstance) ProcessProtocolMsg ¶
func (n *TreeNodeInstance) ProcessProtocolMsg(msg *ProtocolMsg)
ProcessProtocolMsg takes a message and puts it into a queue for later processing. This allows a protocol to have a backlog of messages.
func (*TreeNodeInstance) ProtocolInstance ¶
func (n *TreeNodeInstance) ProtocolInstance() ProtocolInstance
ProtocolInstance returns the instance of the running protocol
func (*TreeNodeInstance) ProtocolName ¶
func (n *TreeNodeInstance) ProtocolName() string
ProtocolName will return the string representing that protocol
func (*TreeNodeInstance) Public ¶
func (n *TreeNodeInstance) Public() kyber.Point
Public returns the public key of the service, either the specific or the default if not available
func (*TreeNodeInstance) Publics ¶
func (n *TreeNodeInstance) Publics() []kyber.Point
Publics makes a list of public keys for the service associated with the instance
func (*TreeNodeInstance) RegisterChannel ¶
func (n *TreeNodeInstance) RegisterChannel(c interface{}) error
RegisterChannel is a compatibility-method for RegisterChannelLength and setting up a channel with length 100.
func (*TreeNodeInstance) RegisterChannelLength ¶
func (n *TreeNodeInstance) RegisterChannelLength(c interface{}, length int) error
RegisterChannelLength takes a channel with a struct that contains two elements: a TreeNode and a message. The second argument is the length of the channel. It will send every message that are the same type to this channel. This function handles also
- registration of the message-type
- aggregation or not of messages: if you give a channel of slices, the messages will be aggregated, else they will come one-by-one
func (*TreeNodeInstance) RegisterChannels ¶
func (n *TreeNodeInstance) RegisterChannels(channels ...interface{}) error
RegisterChannels registers a list of given channels by calling RegisterChannel above
func (*TreeNodeInstance) RegisterChannelsLength ¶
func (n *TreeNodeInstance) RegisterChannelsLength(length int, channels ...interface{}) error
RegisterChannelsLength is a convenience function to register a vararg of channels with a given length.
func (*TreeNodeInstance) RegisterHandler ¶
func (n *TreeNodeInstance) RegisterHandler(c interface{}) error
RegisterHandler takes a function which takes a struct as argument that contains two elements: a TreeNode and a message. It will send every message that are the same type to this channel.
This function also handles:
- registration of the message-type
- aggregation or not of messages: if you give a channel of slices, the messages will be aggregated, otherwise they will come one by one
func (*TreeNodeInstance) RegisterHandlers ¶
func (n *TreeNodeInstance) RegisterHandlers(handlers ...interface{}) error
RegisterHandlers registers a list of given handlers by calling RegisterHandler above
func (*TreeNodeInstance) Root ¶
func (n *TreeNodeInstance) Root() *TreeNode
Root returns the root-node of that tree
func (*TreeNodeInstance) Roster ¶
func (n *TreeNodeInstance) Roster() *Roster
Roster returns the entity-list
func (*TreeNodeInstance) Rx ¶
func (n *TreeNodeInstance) Rx() uint64
Rx implements the CounterIO interface
func (*TreeNodeInstance) SendTo ¶
func (n *TreeNodeInstance) SendTo(to *TreeNode, msg interface{}) error
SendTo sends to a given node
func (*TreeNodeInstance) SendToChildren ¶
func (n *TreeNodeInstance) SendToChildren(msg interface{}) error
SendToChildren sends a given message to all children of the calling node. It stops sending if sending to one of the children fails. In that case it returns an error. If the underlying node is a leaf node this function does nothing.
func (*TreeNodeInstance) SendToChildrenInParallel ¶
func (n *TreeNodeInstance) SendToChildrenInParallel(msg interface{}) []error
SendToChildrenInParallel sends a given message to all children of the calling node. It has the following differences to node.SendToChildren: The actual sending happens in a go routine (in parallel). It continues sending to the other nodes if sending to one of the children fails. In that case it will collect all errors in a slice. If the underlying node is a leaf node this function does nothing.
func (*TreeNodeInstance) SendToParent ¶
func (n *TreeNodeInstance) SendToParent(msg interface{}) error
SendToParent sends a given message to the parent of the calling node (unless it is the root)
func (*TreeNodeInstance) ServerIdentity ¶
func (n *TreeNodeInstance) ServerIdentity() *network.ServerIdentity
ServerIdentity returns our entity
func (*TreeNodeInstance) SetConfig ¶
func (n *TreeNodeInstance) SetConfig(c *GenericConfig) error
SetConfig sets the GenericConfig c to be passed down in the first message alongside with the protocol if it is non nil. This config can later be read by Services in the NewProtocol method.
func (*TreeNodeInstance) Shutdown ¶
func (n *TreeNodeInstance) Shutdown() error
Shutdown - standard Shutdown implementation. Define your own in your protocol (if necessary)
func (*TreeNodeInstance) Suite ¶
func (n *TreeNodeInstance) Suite() network.Suite
Suite can be used to get the kyber.Suite associated with the service. It can be either the default suite or the one registered with the service.
func (*TreeNodeInstance) Token ¶
func (n *TreeNodeInstance) Token() *Token
Token returns a CLONE of the underlying onet.Token struct. Useful for unit testing.
func (*TreeNodeInstance) TokenID ¶
func (n *TreeNodeInstance) TokenID() TokenID
TokenID returns the TokenID of the given node (to uniquely identify it)
func (*TreeNodeInstance) Tree ¶
func (n *TreeNodeInstance) Tree() *Tree
Tree returns the tree of that node. Because the storage keeps the tree around until the protocol is done, this will never return a nil value. It will panic if the tree is nil.
func (*TreeNodeInstance) TreeNode ¶
func (n *TreeNodeInstance) TreeNode() *TreeNode
TreeNode gets the treeNode of this node. If there is no TreeNode for the Token of this node, the function will return nil
func (*TreeNodeInstance) TreeNodeInstance ¶
func (n *TreeNodeInstance) TreeNodeInstance() *TreeNodeInstance
TreeNodeInstance returns itself (XXX quick hack for this services2 branch version for the tests)
func (*TreeNodeInstance) Tx ¶
func (n *TreeNodeInstance) Tx() uint64
Tx implements the CounterIO interface
type WebSocket ¶
type WebSocket struct { TLSConfig *tls.Config // can only be modified before Start is called sync.Mutex // contains filtered or unexported fields }
WebSocket handles incoming client-requests using the websocket protocol. When making a new WebSocket, it will listen one port above the ServerIdentity-port-#. The websocket protocol has been chosen as smallest common denominator for languages including JavaScript.
func NewWebSocket ¶
func NewWebSocket(si *network.ServerIdentity) *WebSocket
NewWebSocket opens a webservice-listener at the given si.URL.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
dummy
Package Dummy's only purpose is to create a DB that can be tested by the dbadmin binary.
|
Package Dummy's only purpose is to create a DB that can be tested by the dbadmin binary. |
Package log is an output-library that can print nicely formatted messages to the screen.
|
Package log is an output-library that can print nicely formatted messages to the screen. |
Package simul allows for easy simulation on different platforms.
|
Package simul allows for easy simulation on different platforms. |
monitor
Package monitor package handle the logging, collection and computation of statistical data.
|
Package monitor package handle the logging, collection and computation of statistical data. |
platform
Package platform contains interface and implementation to run onet code amongst multiple platforms.
|
Package platform contains interface and implementation to run onet code amongst multiple platforms. |