Skip to main content

process_chain_events

Function process_chain_events 

Source
pub(super) async fn process_chain_events<C, G>(
    chain_reader: C,
    graph_updater: G,
    events: impl Stream<Item = ChainEvent> + Send + 'static,
    own_chain_addr: Address,
    own_packet_key: OffchainPublicKey,
    ticket_price: Arc<RwLock<HoprBalance>>,
    win_probability: Arc<RwLock<WinningProbability>>,
    peer_discovery_tx: Option<Sender<(PeerId, Vec<Multiaddr>)>>,
)
where C: ChainKeyOperations + Clone + Send + Sync + 'static, G: NetworkGraphUpdate + Send + Sync + 'static,
Expand description

Processes chain events and records them as graph updates.

Drives the chain-to-graph edge of the topology pipeline: converts incoming on-chain ChainEvents into [NetworkGraphUpdate] calls so the routing graph stays current. When peer_discovery_tx is Some, each [ChainEvent::Announcement] is also forwarded to the p2p network layer so it can initiate connections to newly discovered peers. Runs until the supplied events stream terminates.