Documentation ¶
Overview ¶
Package protocol contains an example demonstrating how to write a protocol and a simulation.
The protocol has two messages:
- Announce which is sent from the root down the tree
- Reply which is sent back up to the root
If you want to add other messages, be sure to follow the way Announce and StructAnnounce are set up.
A simple protocol uses four files: - struct.go defines the messages sent around - protocol.go defines the actions for each message - protocol_test.go tests the protocol in a local test - simulation.go tests the protocol on distant platforms like deterlab
Index ¶
Constants ¶
const Name = "Template"
Name can be used from other packages to refer to this protocol.
Variables ¶
This section is empty.
Functions ¶
func NewProtocol ¶
func NewProtocol(n *onet.TreeNodeInstance) (onet.ProtocolInstance, error)
NewProtocol initialises the structure for use in one round
Types ¶
type Announce ¶
type Announce struct {
Message string
}
Announce is used to pass a message to all children.
type TemplateProtocol ¶
type TemplateProtocol struct { *onet.TreeNodeInstance ChildCount chan int // contains filtered or unexported fields }
TemplateProtocol holds the state of a given protocol.
For this example, it defines a channel that will receive the number of children. Only the root-node will write to the channel.
func (*TemplateProtocol) Dispatch ¶
func (p *TemplateProtocol) Dispatch() error
Dispatch implements the main logic of the protocol. The function is only called once. The protocol is considered finished when Dispatch returns and Done is called.
func (*TemplateProtocol) Start ¶
func (p *TemplateProtocol) Start() error
Start sends the Announce-message to all children