+/// Either [`P2PGossipSync`] or [`RapidGossipSync`].
+pub enum GossipSync<
+ P: Deref<Target = P2PGossipSync<G, A, L>>,
+ R: Deref<Target = RapidGossipSync<G, L>>,
+ G: Deref<Target = NetworkGraph<L>>,
+ A: Deref,
+ L: Deref,
+>
+where A::Target: chain::Access, L::Target: Logger {
+ /// Gossip sync via the lightning peer-to-peer network as defined by BOLT 7.
+ P2P(P),
+ /// Rapid gossip sync from a trusted server.
+ Rapid(R),
+ /// No gossip sync.
+ None,
+}
+
+impl<
+ P: Deref<Target = P2PGossipSync<G, A, L>>,
+ R: Deref<Target = RapidGossipSync<G, L>>,
+ G: Deref<Target = NetworkGraph<L>>,
+ A: Deref,
+ L: Deref,
+> GossipSync<P, R, G, A, L>
+where A::Target: chain::Access, L::Target: Logger {
+ fn network_graph(&self) -> Option<&G> {
+ match self {
+ GossipSync::P2P(gossip_sync) => Some(gossip_sync.network_graph()),
+ GossipSync::Rapid(gossip_sync) => Some(gossip_sync.network_graph()),
+ GossipSync::None => None,
+ }
+ }
+
+ fn prunable_network_graph(&self) -> Option<&G> {
+ match self {
+ GossipSync::P2P(gossip_sync) => Some(gossip_sync.network_graph()),
+ GossipSync::Rapid(gossip_sync) => {
+ if gossip_sync.is_initial_sync_complete() {
+ Some(gossip_sync.network_graph())
+ } else {
+ None
+ }
+ },
+ GossipSync::None => None,
+ }
+ }
+}