Skip to content

Commit 3a008d3

Browse files
committed
Introduce ALiquidityManager trait
.. in order to make handling generics easier, just as we do with `AChannelManager`, `AOnionMessenger`, etc.
1 parent db5b0f3 commit 3a008d3

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

lightning-liquidity/src/manager.rs

+39
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,45 @@ pub struct LiquidityClientConfig {
6868
pub lsps2_client_config: Option<LSPS2ClientConfig>,
6969
}
7070

71+
/// A trivial trait which describes any [`LiquidityManager`].
72+
///
73+
/// This is not exported to bindings users as general cover traits aren't useful in other
74+
/// languages.
75+
pub trait ALiquidityManager {
76+
/// A type implementing [`EntropySource`]
77+
type EntropySource: EntropySource + ?Sized;
78+
/// A type that may be dereferenced to [`Self::EntropySource`].
79+
type ES: Deref<Target = Self::EntropySource> + Clone;
80+
/// A type implementing [`AChannelManager`]
81+
type AChannelManager: AChannelManager + ?Sized;
82+
/// A type that may be dereferenced to [`Self::AChannelManager`].
83+
type CM: Deref<Target = Self::AChannelManager> + Clone;
84+
/// A type implementing [`Filter`].
85+
type Filter: Filter + ?Sized;
86+
/// A type that may be dereferenced to [`Self::Filter`].
87+
type C: Deref<Target = Self::Filter> + Clone;
88+
/// Returns a reference to the actual [`LiquidityManager`] object.
89+
fn get_lm(&self) -> &LiquidityManager<Self::ES, Self::CM, Self::C>;
90+
}
91+
92+
impl<ES: Deref + Clone, CM: Deref + Clone, C: Deref + Clone> ALiquidityManager
93+
for LiquidityManager<ES, CM, C>
94+
where
95+
ES::Target: EntropySource,
96+
CM::Target: AChannelManager,
97+
C::Target: Filter,
98+
{
99+
type EntropySource = ES::Target;
100+
type ES = ES;
101+
type AChannelManager = CM::Target;
102+
type CM = CM;
103+
type Filter = C::Target;
104+
type C = C;
105+
fn get_lm(&self) -> &LiquidityManager<ES, CM, C> {
106+
self
107+
}
108+
}
109+
71110
/// The main interface into LSP functionality.
72111
///
73112
/// Should be used as a [`CustomMessageHandler`] for your [`PeerManager`]'s [`MessageHandler`].

0 commit comments

Comments
 (0)