Module P2p_ringcast_lwt.Make
Functor building an implementation of Ringcast with Lwt given a Node_id
, Node
, gossip View
, RingCast Gossip
protocol, and an Io
event handler module.
Parameters
Node_id : P2p.S.NODE_ID
Node : P2p.S.NODE with type nid := Node_id.t
View : P2p.S.VIEW with type nid := Node_id.t and type node := Node.t
Msg_id : P2p.S.MSG_ID
Ringcast : P2p.S.GOSSIP_DISSEM with type nid := Node_id.t and type node := Node.t and type view := View.t and type mid := Msg_id.t
Io : S.RINGCAST_IO with type nid := Node_id.t and type node := Node.t and type view := View.t and type mid := Msg_id.t
Signature
val init : me:node -> view:view -> view_len:int -> xchg_len:int -> period:float -> fanout:int -> seen_len:int -> io:io -> t
init node view view_len xchg_len period fanout seen_cap
initializes a RingCast instance with the following configuration.- parameter me
this node
- parameter view
initial view
- parameter view_len
max view length
- parameter xchg_len
number of entries to exchange at each period
- parameter period
gossip period, in seconds
- parameter fanout
dissemination fanout
- parameter seen_len
length of queue of last seen message IDs
val run : ?stop:unit Lwt.t -> t -> unit Lwt.t
run ?stop t
runs initiator thread: picks a random node fromview
to gossip with everyperiod
seconds.If
?stop
is provided, this initiator thread returns as soon as thestop
thread is fulfilled.
val shutdown : t -> unit
shutdown t
stops initiator thread.In case
run
was called with astop
argument, thestop
thread is cancelled, otherwise it is fulfilled.
val respond : t -> node -> view -> view Lwt.t
respond t node recvd
merges received entries from a node and sends response
val forward : t -> node -> mid -> Cstruct.t -> unit Lwt.t
forward t src mid msg
receives a message (msgid, msg
) from asrc
node and selects nodes from the local view it should be forwarded to (predecessor or successor on the ring and some random nodes, limited byfanout
); callsIo.send_msg
for each selected node