Section2.2 Event
fabric中关于事件处理的大概包括: 网络层的消息传递, 从网络层生成时间向consensus的传递, consensus内部的时间传递, 以及consensus向外的事件传递.
对于网络层, 我们不关心其机制.
对于网络层向consensus, fabric采用了MessageFan, 在程序初始化时会启动, 然后不断地交给consensus处理(进入consensus内部).
在consensus内部, 采用了event.Manager, 每一个需要处理事件的结构都需要实现函数func ProcessEvent(), 然后初始化一个event.Manager, 需要该结构处理的事件都将发送给event.Manager, 由Manager是一个一直运行的线程, 在收到消息后就会调用func ProcessEvent()来处理事件.
对于consensus向外的发送, 是指向外部节点发送消息, 是通过一层层的调用, 最终调用到网络层的广播, 单播函数.
[fabric event (stream to consenter)](https://github.com/yeongchingtarn/geth-pbft/wiki/fabric-event-(stream-to-consenter))
[fabric event (consenter to pbft)](https://github.com/yeongchingtarn/geth-pbft/wiki/fabric-event-(consenter-to-pbft))
[fabric event (pbft to network)](https://github.com/yeongchingtarn/geth-pbft/wiki/fabric-event-(pbft-to-network))
Last updated
Was this helpful?