## sn_routing internal components and execution flow ###### tags: `routing` `design` #### Notes: - The `Comm` component is not included in the diagram for simplicity, and messages are shown as sent directly to qp2p in the diagram. - The `Stage` component has read-only access to the `SectionInfo`. This shall give us higher concurrency/throughput for processing messages. - The `SectionInfo` is a wrapper exposing APIs for reading states and applying operations from/to `EldersBftCrdt`, `AdultsBftCrdt`, and `KeyChainBftCrdt`BFT-CRDT containers. ```plantuml participant qp2p participant Executor as exec #lightblue participant Stage as stage #lightblue participant SectionInfo as section_info #lightblue participant EldersBftCrdt as elders #lightblue participant EventStream as events #lightblue qp2p -> exec: new_message(msg) exec -> stage: process_message(msg) stage -> stage: processing msg\naccordingly note left e.g. new Peer has to be added end note stage -> section_info: add_peer(msg.source) section_info -> elders: add_peer(msg.source) elders -[#blue]-> section_info: packets section_info -[#blue]-> stage: packets stage -> events: event("Peer Joining") note left the process may also imply reporting events to the user end note stage -[#blue]-> exec: packets loop each packet in packets alt if packet.dst is us exec -> section_info: apply_to_elders(packet) section_info -> elders: apply(packet) else packet.dst is not us exec -> qp2p: send_to(packet.dst, packet) end end ```