@@ -18,24 +18,19 @@ use lightning_types::features::{InitFeatures, NodeFeatures};
1818
1919use crate :: liquidity:: LiquiditySource ;
2020
21- pub ( crate ) enum NodeCustomMessageHandler < L : Deref >
21+ pub ( crate ) struct NodeCustomMessageHandler < L : Deref >
2222where
2323 L :: Target : Logger ,
2424{
25- Ignoring ,
26- Liquidity { liquidity_source : Arc < LiquiditySource < L > > } ,
25+ liquidity_source : Arc < LiquiditySource < L > > ,
2726}
2827
2928impl < L : Deref > NodeCustomMessageHandler < L >
3029where
3130 L :: Target : Logger ,
3231{
33- pub ( crate ) fn new_liquidity ( liquidity_source : Arc < LiquiditySource < L > > ) -> Self {
34- Self :: Liquidity { liquidity_source }
35- }
36-
37- pub ( crate ) fn new_ignoring ( ) -> Self {
38- Self :: Ignoring
32+ pub ( crate ) fn new ( liquidity_source : Arc < LiquiditySource < L > > ) -> Self {
33+ Self { liquidity_source }
3934 }
4035}
4136
4843 fn read < RD : LengthLimitedRead > (
4944 & self , message_type : u16 , buffer : & mut RD ,
5045 ) -> Result < Option < Self :: CustomMessage > , lightning:: ln:: msgs:: DecodeError > {
51- match self {
52- Self :: Ignoring => Ok ( None ) ,
53- Self :: Liquidity { liquidity_source, .. } => {
54- liquidity_source. liquidity_manager ( ) . read ( message_type, buffer)
55- } ,
56- }
46+ self . liquidity_source . liquidity_manager ( ) . read ( message_type, buffer)
5747 }
5848}
5949
@@ -64,58 +54,28 @@ where
6454 fn handle_custom_message (
6555 & self , msg : Self :: CustomMessage , sender_node_id : PublicKey ,
6656 ) -> Result < ( ) , lightning:: ln:: msgs:: LightningError > {
67- match self {
68- Self :: Ignoring => Ok ( ( ) ) , // Should be unreachable!() as the reader will return `None`
69- Self :: Liquidity { liquidity_source, .. } => {
70- liquidity_source. liquidity_manager ( ) . handle_custom_message ( msg, sender_node_id)
71- } ,
72- }
57+ self . liquidity_source . liquidity_manager ( ) . handle_custom_message ( msg, sender_node_id)
7358 }
7459
7560 fn get_and_clear_pending_msg ( & self ) -> Vec < ( PublicKey , Self :: CustomMessage ) > {
76- match self {
77- Self :: Ignoring => Vec :: new ( ) ,
78- Self :: Liquidity { liquidity_source, .. } => {
79- liquidity_source. liquidity_manager ( ) . get_and_clear_pending_msg ( )
80- } ,
81- }
61+ self . liquidity_source . liquidity_manager ( ) . get_and_clear_pending_msg ( )
8262 }
8363
8464 fn provided_node_features ( & self ) -> NodeFeatures {
85- match self {
86- Self :: Ignoring => NodeFeatures :: empty ( ) ,
87- Self :: Liquidity { liquidity_source, .. } => {
88- liquidity_source. liquidity_manager ( ) . provided_node_features ( )
89- } ,
90- }
65+ self . liquidity_source . liquidity_manager ( ) . provided_node_features ( )
9166 }
9267
9368 fn provided_init_features ( & self , their_node_id : PublicKey ) -> InitFeatures {
94- match self {
95- Self :: Ignoring => InitFeatures :: empty ( ) ,
96- Self :: Liquidity { liquidity_source, .. } => {
97- liquidity_source. liquidity_manager ( ) . provided_init_features ( their_node_id)
98- } ,
99- }
69+ self . liquidity_source . liquidity_manager ( ) . provided_init_features ( their_node_id)
10070 }
10171
10272 fn peer_connected (
10373 & self , their_node_id : PublicKey , msg : & lightning:: ln:: msgs:: Init , inbound : bool ,
10474 ) -> Result < ( ) , ( ) > {
105- match self {
106- Self :: Ignoring => Ok ( ( ) ) ,
107- Self :: Liquidity { liquidity_source, .. } => {
108- liquidity_source. liquidity_manager ( ) . peer_connected ( their_node_id, msg, inbound)
109- } ,
110- }
75+ self . liquidity_source . liquidity_manager ( ) . peer_connected ( their_node_id, msg, inbound)
11176 }
11277
11378 fn peer_disconnected ( & self , their_node_id : PublicKey ) {
114- match self {
115- Self :: Ignoring => { } ,
116- Self :: Liquidity { liquidity_source, .. } => {
117- liquidity_source. liquidity_manager ( ) . peer_disconnected ( their_node_id)
118- } ,
119- }
79+ self . liquidity_source . liquidity_manager ( ) . peer_disconnected ( their_node_id)
12080 }
12181}
0 commit comments