@@ -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
@@ -67,6 +67,73 @@ macro_rules! log_route {
67
67
}
68
68
}
69
69
70
+ pub ( crate ) struct DebugDirectionalChannelInfo < ' a > ( pub & ' a DirectionalChannelInfo ) ;
71
+ impl < ' a > std:: fmt:: Display for DebugDirectionalChannelInfo < ' a > {
72
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> Result < ( ) , std:: fmt:: Error > {
73
+ 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) ?;
74
+ Ok ( ( ) )
75
+ }
76
+ }
77
+ macro_rules! log_directionalchannelinfo {
78
+ ( $obj: expr) => {
79
+ :: util:: macro_logger:: DebugDirectionalChannelInfo ( & $obj)
80
+ }
81
+ }
82
+
83
+ pub ( crate ) struct DebugChannelInfo < ' a > ( pub & ' a ChannelInfo ) ;
84
+ impl < ' a > std:: fmt:: Display for DebugChannelInfo < ' a > {
85
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> Result < ( ) , std:: fmt:: Error > {
86
+ //TODO: GlobalFeatures
87
+ write ! ( f, " one_to_two {}" , log_directionalchannelinfo!( self . 0 . one_to_two) ) ?;
88
+ write ! ( f, " two_to_one {}" , log_directionalchannelinfo!( self . 0 . two_to_one) ) ?;
89
+ Ok ( ( ) )
90
+ }
91
+ }
92
+ macro_rules! log_channelinfo {
93
+ ( $obj: expr) => {
94
+ :: util:: macro_logger:: DebugChannelInfo ( & $obj)
95
+ }
96
+ }
97
+
98
+ pub ( crate ) struct DebugNodeInfo < ' a > ( pub & ' a NodeInfo ) ;
99
+ impl < ' a > std:: fmt:: Display for DebugNodeInfo < ' a > {
100
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> Result < ( ) , std:: fmt:: Error > {
101
+ write ! ( f, " Channels\n " ) ?;
102
+ for c in self . 0 . channels . iter ( ) {
103
+ write ! ( f, " {}\n " , c) ?;
104
+ }
105
+ write ! ( f, " lowest_inbound_channel_fee_base_msat {}\n " , self . 0 . lowest_inbound_channel_fee_base_msat) ?;
106
+ write ! ( f, " lowest_inbound_channel_fee_proportional_millionths {}\n " , self . 0 . lowest_inbound_channel_fee_proportional_millionths) ?;
107
+ //TODO: GlobalFeatures, last_update, rgb, alias, addresses
108
+ Ok ( ( ) )
109
+ }
110
+ }
111
+ macro_rules! log_nodeinfo {
112
+ ( $obj: expr) => {
113
+ :: util:: macro_logger:: DebugNodeInfo ( & $obj)
114
+ }
115
+ }
116
+
117
+ pub ( crate ) struct DebugNetworkMap < ' a > ( pub & ' a NetworkMap ) ;
118
+ impl < ' a > std:: fmt:: Display for DebugNetworkMap < ' a > {
119
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> Result < ( ) , std:: fmt:: Error > {
120
+ write ! ( f, "Node id {} network map\n [Channels]\n " , log_pubkey!( self . 0 . our_node_id) ) ?;
121
+ for ( key, val) in self . 0 . channels . iter ( ) {
122
+ write ! ( f, " {} :\n {}\n " , key, log_channelinfo!( val) ) ?;
123
+ }
124
+ write ! ( f, "[Nodes]\n " ) ?;
125
+ for ( key, val) in self . 0 . nodes . iter ( ) {
126
+ write ! ( f, " {} :\n {}\n " , log_pubkey!( key) , log_nodeinfo!( val) ) ?;
127
+ }
128
+ Ok ( ( ) )
129
+ }
130
+ }
131
+ macro_rules! log_networkmap {
132
+ ( $obj: expr) => {
133
+ :: util:: macro_logger:: DebugNetworkMap ( & $obj)
134
+ }
135
+ }
136
+
70
137
macro_rules! log_internal {
71
138
( $self: ident, $lvl: expr, $( $arg: tt) +) => (
72
139
& $self. logger. log( & Record :: new( $lvl, format_args!( $( $arg) +) , module_path!( ) , file!( ) , line!( ) ) ) ;
0 commit comments