@@ -12,6 +12,7 @@ use std::cmp;
12
12
use std:: sync:: { RwLock , Arc } ;
13
13
use std:: collections:: { HashMap , BinaryHeap } ;
14
14
use std:: collections:: hash_map:: Entry ;
15
+ use std;
15
16
16
17
/// A hop in a route
17
18
#[ derive( Clone ) ]
@@ -35,31 +36,46 @@ pub struct Route {
35
36
pub hops : Vec < RouteHop > ,
36
37
}
37
38
38
- //Here, DirectionalChannelInfo, ChannelInfo, NodeInfo and NetworkMap are pub(crate) only for log_* macros access
39
- pub ( crate ) struct DirectionalChannelInfo {
40
- pub ( crate ) src_node_id : PublicKey ,
41
- pub ( crate ) last_update : u32 ,
42
- pub ( crate ) enabled : bool ,
43
- pub ( crate ) cltv_expiry_delta : u16 ,
44
- pub ( crate ) htlc_minimum_msat : u64 ,
45
- pub ( crate ) fee_base_msat : u32 ,
46
- pub ( crate ) fee_proportional_millionths : u32 ,
39
+ struct DirectionalChannelInfo {
40
+ src_node_id : PublicKey ,
41
+ last_update : u32 ,
42
+ enabled : bool ,
43
+ cltv_expiry_delta : u16 ,
44
+ htlc_minimum_msat : u64 ,
45
+ fee_base_msat : u32 ,
46
+ fee_proportional_millionths : u32 ,
47
47
}
48
48
49
- pub ( crate ) struct ChannelInfo {
50
- pub ( crate ) features : GlobalFeatures ,
51
- pub ( crate ) one_to_two : DirectionalChannelInfo ,
52
- pub ( crate ) two_to_one : DirectionalChannelInfo ,
49
+ impl std:: fmt:: Display for DirectionalChannelInfo {
50
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> Result < ( ) , std:: fmt:: Error > {
51
+ write ! ( f, " node id {} last_update {} enabled {} cltv_expiry_delta {} htlc_minimum_msat {} fee_base_msat {} fee_proportional_millionths {}\n " , log_pubkey!( self . src_node_id) , self . last_update, self . enabled, self . cltv_expiry_delta, self . htlc_minimum_msat, self . fee_base_msat, self . fee_proportional_millionths) ?;
52
+ Ok ( ( ) )
53
+ }
53
54
}
54
55
55
- pub ( crate ) struct NodeInfo {
56
+ struct ChannelInfo {
57
+ features : GlobalFeatures ,
58
+ one_to_two : DirectionalChannelInfo ,
59
+ two_to_one : DirectionalChannelInfo ,
60
+ }
61
+
62
+ impl std:: fmt:: Display for ChannelInfo {
63
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> Result < ( ) , std:: fmt:: Error > {
64
+ //TODO: GlobalFeatures
65
+ write ! ( f, " one_to_two {}" , self . one_to_two) ?;
66
+ write ! ( f, " two_to_one {}" , self . two_to_one) ?;
67
+ Ok ( ( ) )
68
+ }
69
+ }
70
+
71
+ struct NodeInfo {
56
72
#[ cfg( feature = "non_bitcoin_chain_hash_routing" ) ]
57
73
channels : Vec < ( u64 , Sha256dHash ) > ,
58
74
#[ cfg( not( feature = "non_bitcoin_chain_hash_routing" ) ) ]
59
- pub ( crate ) channels : Vec < u64 > ,
75
+ channels : Vec < u64 > ,
60
76
61
- pub ( crate ) lowest_inbound_channel_fee_base_msat : u32 ,
62
- pub ( crate ) lowest_inbound_channel_fee_proportional_millionths : u32 ,
77
+ lowest_inbound_channel_fee_base_msat : u32 ,
78
+ lowest_inbound_channel_fee_proportional_millionths : u32 ,
63
79
64
80
features : GlobalFeatures ,
65
81
last_update : u32 ,
@@ -68,14 +84,41 @@ pub(crate) struct NodeInfo {
68
84
addresses : Vec < NetAddress > ,
69
85
}
70
86
71
- pub ( crate ) struct NetworkMap {
87
+ impl std:: fmt:: Display for NodeInfo {
88
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> Result < ( ) , std:: fmt:: Error > {
89
+ write ! ( f, " Channels\n " ) ?;
90
+ for c in self . channels . iter ( ) {
91
+ write ! ( f, " {}\n " , c) ?;
92
+ }
93
+ write ! ( f, " lowest_inbound_channel_fee_base_msat {}\n " , self . lowest_inbound_channel_fee_base_msat) ?;
94
+ write ! ( f, " lowest_inbound_channel_fee_proportional_millionths {}\n " , self . lowest_inbound_channel_fee_proportional_millionths) ?;
95
+ //TODO: GlobalFeatures, last_update, rgb, alias, addresses
96
+ Ok ( ( ) )
97
+ }
98
+ }
99
+
100
+ struct NetworkMap {
72
101
#[ cfg( feature = "non_bitcoin_chain_hash_routing" ) ]
73
102
channels : HashMap < ( u64 , Sha256dHash ) , ChannelInfo > ,
74
103
#[ cfg( not( feature = "non_bitcoin_chain_hash_routing" ) ) ]
75
- pub ( crate ) channels : HashMap < u64 , ChannelInfo > ,
104
+ channels : HashMap < u64 , ChannelInfo > ,
76
105
77
- pub ( crate ) our_node_id : PublicKey ,
78
- pub ( crate ) nodes : HashMap < PublicKey , NodeInfo > ,
106
+ our_node_id : PublicKey ,
107
+ nodes : HashMap < PublicKey , NodeInfo > ,
108
+ }
109
+
110
+ impl std:: fmt:: Display for NetworkMap {
111
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> Result < ( ) , std:: fmt:: Error > {
112
+ write ! ( f, "Node id {} network map\n [Channels]\n " , log_pubkey!( self . our_node_id) ) ?;
113
+ for ( key, val) in self . channels . iter ( ) {
114
+ write ! ( f, " {} :\n {}\n " , key, val) ?;
115
+ }
116
+ write ! ( f, "[Nodes]\n " ) ?;
117
+ for ( key, val) in self . nodes . iter ( ) {
118
+ write ! ( f, " {} :\n {}\n " , log_pubkey!( key) , val) ?;
119
+ }
120
+ Ok ( ( ) )
121
+ }
79
122
}
80
123
81
124
impl NetworkMap {
0 commit comments