Documentation
¶
Overview ¶
Package example_channels contains an example demonstrating how to write a protocol and a simulation using channels for message communication.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewExampleChannels ¶
func NewExampleChannels(n *sda.TreeNodeInstance) (sda.ProtocolInstance, error)
NewExampleChannels initialises the structure for use in one round
func NewSimulation ¶
func NewSimulation(config string) (sda.Simulation, error)
NewSimulation is used internally to register the simulation.
Types ¶
type Announce ¶
type Announce struct {
Message string
}
Announce is used to pass a message to all children
type ProtocolExampleChannels ¶
type ProtocolExampleChannels struct { *sda.TreeNodeInstance Message string ChildCount chan int ChannelAnnounce chan StructAnnounce ChannelReply chan []StructReply }
ProtocolExampleChannels just holds a message that is passed to all children. It also defines a channel that will receive the number of children. Only the root-node will write to the channel.
func (*ProtocolExampleChannels) Dispatch ¶
func (p *ProtocolExampleChannels) Dispatch() error
Dispatch is an infinite loop to handle messages from channels
func (*ProtocolExampleChannels) Start ¶
func (p *ProtocolExampleChannels) Start() error
Starts the protocol
type Simulation ¶
type Simulation struct {
sda.SimulationBFTree
}
Simulation implements sda.Simulation.
func (*Simulation) Run ¶
func (e *Simulation) Run(config *sda.SimulationConfig) error
Run implements sda.Simulation.
func (*Simulation) Setup ¶
func (e *Simulation) Setup(dir string, hosts []string) ( *sda.SimulationConfig, error)
Setup implements sda.Simulation.
type StructAnnounce ¶
StructAnnounce contains Announce and the data necessary to identify the message in the sda framework.
type StructReply ¶
StructReply contains Reply and the data necessary to identify the message in the sda framework.