routing.rs

Overview

The routing.rs file provides functionality to determine the routing destination within the system for messages of type AuthoritySwitch. It contains a single public function, route, that extracts the appropriate ThreadIdentifier from various variants of the AuthoritySwitch enum. This routing mechanism is essential for directing messages to the correct processing thread based on the message content.

Function

route

pub fn route(message: &AuthoritySwitch) -> ThreadIdentifier

Implementation Details

External Types and Modules

Interaction With Other Parts of the System

Diagram

flowchart TD
A["route(message: &AuthoritySwitch)"] --> B{Match message variant}
B --> C["Request(e)"]
B --> D["Reject(e)"]
B --> E["RejectTooOld(e)"]
B --> F["Switched(e)"]
B --> G["Failed(e)"]
C --> H[Lock envelope e]
H --> I[Access data -> height -> thread_identifier]
I --> J[Return ThreadIdentifier]
D --> K[Access thread_identifier from envelope e]
K --> J
E --> L[ThreadIdentifier stored directly]
L --> J
F --> M[Access data -> block_height -> thread_identifier]
M --> J
G --> N[Access data -> block_height -> thread_identifier]
N --> J

This flowchart illustrates the routing logic based on matching the AuthoritySwitch message variant and extracting the corresponding ThreadIdentifier to determine the routing destination.