@@ -27,6 +27,7 @@ mod defined_activity;
27
27
pub mod lnd;
28
28
mod random_activity;
29
29
mod serializers;
30
+ pub mod sim_node;
30
31
#[ cfg( test) ]
31
32
mod test_utils;
32
33
@@ -84,6 +85,37 @@ impl std::fmt::Display for NodeId {
84
85
}
85
86
}
86
87
88
+ /// Represents a short channel ID, expressed as a struct so that we can implement display for the trait.
89
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Copy ) ]
90
+ pub struct ShortChannelID ( u64 ) ;
91
+
92
+ /// Utility function to easily convert from u64 to `ShortChannelID`
93
+ impl From < u64 > for ShortChannelID {
94
+ fn from ( value : u64 ) -> Self {
95
+ ShortChannelID ( value)
96
+ }
97
+ }
98
+
99
+ /// Utility function to easily convert `ShortChannelID` into u64
100
+ impl From < ShortChannelID > for u64 {
101
+ fn from ( scid : ShortChannelID ) -> Self {
102
+ scid. 0
103
+ }
104
+ }
105
+
106
+ /// See https://github.com/lightning/bolts/blob/60de4a09727c20dea330f9ee8313034de6e50594/07-routing-gossip.md#definition-of-short_channel_id.
107
+ impl std:: fmt:: Display for ShortChannelID {
108
+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
109
+ write ! (
110
+ f,
111
+ "{}:{}:{}" ,
112
+ ( self . 0 >> 40 ) as u32 ,
113
+ ( ( self . 0 >> 16 ) & 0xFFFFFF ) as u32 ,
114
+ ( self . 0 & 0xFFFF ) as u16 ,
115
+ )
116
+ }
117
+ }
118
+
87
119
#[ derive( Debug , Serialize , Deserialize , Clone ) ]
88
120
pub struct SimParams {
89
121
pub nodes : Vec < NodeConnection > ,
@@ -133,6 +165,8 @@ pub enum SimulationError {
133
165
FileError ,
134
166
#[ error( "{0}" ) ]
135
167
RandomActivityError ( RandomActivityError ) ,
168
+ #[ error( "Simulated Network Error: {0}" ) ]
169
+ SimulatedNetworkError ( String ) ,
136
170
}
137
171
138
172
#[ derive( Debug , Error ) ]
0 commit comments