Skip to content

Commit a5dbe54

Browse files
committed
Add convenient GossipSync variant constructors
These constructors fill in the missing types for each variant so that users don't have to turbofish them manually.
1 parent f3d5b94 commit a5dbe54

File tree

1 file changed

+46
-0
lines changed
  • lightning-background-processor/src

1 file changed

+46
-0
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,52 @@ where A::Target: chain::Access, L::Target: Logger {
137137
}
138138
}
139139

140+
impl<P: Deref<Target = P2PGossipSync<G, A, L>>, G: Deref<Target = NetworkGraph<L>>, A: Deref, L: Deref>
141+
GossipSync<P, Arc<RapidGossipSync<G, L>>, G, A, L>
142+
where
143+
A::Target: chain::Access,
144+
L::Target: Logger,
145+
{
146+
/// Initializes a new [`GossipSync::P2P`] variant.
147+
pub fn p2p(gossip_sync: P) -> Self {
148+
GossipSync::P2P(gossip_sync)
149+
}
150+
}
151+
152+
impl<R: Deref<Target = RapidGossipSync<G, L>>, G: Deref<Target = NetworkGraph<L>>, L: Deref>
153+
GossipSync<
154+
Arc<P2PGossipSync<G, Arc<dyn chain::Access + Send + Sync>, L>>,
155+
R,
156+
G,
157+
Arc<dyn chain::Access + Send + Sync>,
158+
L,
159+
>
160+
where
161+
L::Target: Logger,
162+
{
163+
/// Initializes a new [`GossipSync::Rapid`] variant.
164+
pub fn rapid(gossip_sync: R) -> Self {
165+
GossipSync::Rapid(gossip_sync)
166+
}
167+
}
168+
169+
impl<L: Deref>
170+
GossipSync<
171+
Arc<P2PGossipSync<Arc<NetworkGraph<L>>, Arc<dyn chain::Access + Send + Sync>, L>>,
172+
Arc<RapidGossipSync<Arc<NetworkGraph<L>>, L>>,
173+
Arc<NetworkGraph<L>>,
174+
Arc<dyn chain::Access + Send + Sync>,
175+
L,
176+
>
177+
where
178+
L::Target: Logger,
179+
{
180+
/// Initializes a new [`GossipSync::None`] variant.
181+
pub fn none() -> Self {
182+
GossipSync::None
183+
}
184+
}
185+
140186
/// Decorates an [`EventHandler`] with common functionality provided by standard [`EventHandler`]s.
141187
struct DecoratingEventHandler<
142188
'a,

0 commit comments

Comments
 (0)