@@ -3,7 +3,7 @@ use chain::transaction::OutPoint;
3
3
use bitcoin:: util:: hash:: Sha256dHash ;
4
4
use secp256k1:: key:: PublicKey ;
5
5
6
- use ln:: router:: Route ;
6
+ use ln:: router:: { Route , NetworkMap , ChannelInfo , NodeInfo , DirectionalChannelInfo } ;
7
7
8
8
use std;
9
9
@@ -52,6 +52,7 @@ macro_rules! log_funding_channel_id {
52
52
}
53
53
}
54
54
55
+ #[ allow( dead_code) ]
55
56
pub ( crate ) struct DebugRoute < ' a > ( pub & ' a Route ) ;
56
57
impl < ' a > std:: fmt:: Display for DebugRoute < ' a > {
57
58
fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> Result < ( ) , std:: fmt:: Error > {
@@ -61,11 +62,86 @@ impl<'a> std::fmt::Display for DebugRoute<'a> {
61
62
Ok ( ( ) )
62
63
}
63
64
}
65
+ #[ allow( unused_macros) ]
64
66
macro_rules! log_route {
65
67
( $obj: expr) => {
66
68
:: util:: macro_logger:: DebugRoute ( & $obj)
67
69
}
68
70
}
71
+ #[ allow( dead_code) ]
72
+ pub ( crate ) struct DebugDirectionalChannelInfo < ' a > ( pub & ' a DirectionalChannelInfo ) ;
73
+ impl < ' a > std:: fmt:: Display for DebugDirectionalChannelInfo < ' a > {
74
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> Result < ( ) , std:: fmt:: Error > {
75
+ write ! ( f, " node id {} last_update {} enabled {} cltv_expiry_delta {} htlc_minimum_msat {} fee_base_msat {} fee_proportional_millionths {}\n " , log_pubkey!( self . 0 . src_node_id) , self . 0 . last_update, self . 0 . enabled, self . 0 . cltv_expiry_delta, self . 0 . htlc_minimum_msat, self . 0 . fee_base_msat, self . 0 . fee_proportional_millionths) ?;
76
+ Ok ( ( ) )
77
+ }
78
+ }
79
+ #[ allow( unused_macros) ]
80
+ macro_rules! log_directionalchannelinfo {
81
+ ( $obj: expr) => {
82
+ :: util:: macro_logger:: DebugDirectionalChannelInfo ( & $obj)
83
+ }
84
+ }
85
+
86
+ #[ allow( dead_code) ]
87
+ pub ( crate ) struct DebugChannelInfo < ' a > ( pub & ' a ChannelInfo ) ;
88
+ impl < ' a > std:: fmt:: Display for DebugChannelInfo < ' a > {
89
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> Result < ( ) , std:: fmt:: Error > {
90
+ //TODO: GlobalFeatures
91
+ write ! ( f, " one_to_two {}" , log_directionalchannelinfo!( self . 0 . one_to_two) ) ?;
92
+ write ! ( f, " two_to_one {}" , log_directionalchannelinfo!( self . 0 . two_to_one) ) ?;
93
+ Ok ( ( ) )
94
+ }
95
+ }
96
+ #[ allow( unused_macros) ]
97
+ macro_rules! log_channelinfo {
98
+ ( $obj: expr) => {
99
+ :: util:: macro_logger:: DebugChannelInfo ( & $obj)
100
+ }
101
+ }
102
+
103
+ #[ allow( dead_code) ]
104
+ pub ( crate ) struct DebugNodeInfo < ' a > ( pub & ' a NodeInfo ) ;
105
+ impl < ' a > std:: fmt:: Display for DebugNodeInfo < ' a > {
106
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> Result < ( ) , std:: fmt:: Error > {
107
+ write ! ( f, " Channels\n " ) ?;
108
+ for c in self . 0 . channels . iter ( ) {
109
+ write ! ( f, " {}\n " , c) ?;
110
+ }
111
+ write ! ( f, " lowest_inbound_channel_fee_base_msat {}\n " , self . 0 . lowest_inbound_channel_fee_base_msat) ?;
112
+ write ! ( f, " lowest_inbound_channel_fee_proportional_millionths {}\n " , self . 0 . lowest_inbound_channel_fee_proportional_millionths) ?;
113
+ //TODO: GlobalFeatures, last_update, rgb, alias, addresses
114
+ Ok ( ( ) )
115
+ }
116
+ }
117
+ #[ allow( unused_macros) ]
118
+ macro_rules! log_nodeinfo {
119
+ ( $obj: expr) => {
120
+ :: util:: macro_logger:: DebugNodeInfo ( & $obj)
121
+ }
122
+ }
123
+
124
+ #[ allow( dead_code) ]
125
+ pub ( crate ) struct DebugNetworkMap < ' a > ( pub & ' a NetworkMap ) ;
126
+ impl < ' a > std:: fmt:: Display for DebugNetworkMap < ' a > {
127
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> Result < ( ) , std:: fmt:: Error > {
128
+ write ! ( f, "Node id {} network map\n [Channels]\n " , log_pubkey!( self . 0 . our_node_id) ) ?;
129
+ for ( key, val) in self . 0 . channels . iter ( ) {
130
+ write ! ( f, " {} :\n {}\n " , key, log_channelinfo!( val) ) ?;
131
+ }
132
+ write ! ( f, "[Nodes]\n " ) ?;
133
+ for ( key, val) in self . 0 . nodes . iter ( ) {
134
+ write ! ( f, " {} :\n {}\n " , log_pubkey!( key) , log_nodeinfo!( val) ) ?;
135
+ }
136
+ Ok ( ( ) )
137
+ }
138
+ }
139
+ #[ allow( unused_macros) ]
140
+ macro_rules! log_networkmap {
141
+ ( $obj: expr) => {
142
+ :: util:: macro_logger:: DebugNetworkMap ( & $obj)
143
+ }
144
+ }
69
145
70
146
macro_rules! log_internal {
71
147
( $self: ident, $lvl: expr, $( $arg: tt) +) => (
0 commit comments