Skip to main content

process_chain_events

Function process_chain_events 

Source
pub(super) async fn process_chain_events<C, G, S>(
    chain_reader: C,
    graph_updater: G,
    surb_store: S,
    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<CrossfireSink<(PeerId, Vec<Multiaddr>)>>,
)
where C: ChainKeyOperations + Clone + Send + Sync + 'static, G: NetworkGraphUpdate + Send + Sync + 'static, S: SurbStore + 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.

Status changes on our own outgoing channels are also reported to surb_store, so SURBs whose return path starts at a relayer we can no longer pay are shed rather than replied with.

Runs until the supplied events stream terminates.