File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ use async_trait:: async_trait;
2
+ use std:: time:: { Duration , SystemTime } ;
3
+ use tokio:: time;
4
+
5
+ #[ async_trait]
6
+ pub trait Clock : Send + Sync {
7
+ fn now ( & self ) -> SystemTime ;
8
+ async fn sleep ( & self , wait : Duration ) ;
9
+ }
10
+
11
+ /// Provides a wall clock implementation of the Clock trait.
12
+ #[ derive( Clone ) ]
13
+ pub struct SystemClock { }
14
+
15
+ #[ async_trait]
16
+ impl Clock for SystemClock {
17
+ fn now ( & self ) -> SystemTime {
18
+ SystemTime :: now ( )
19
+ }
20
+
21
+ async fn sleep ( & self , wait : Duration ) {
22
+ time:: sleep ( wait) . await ;
23
+ }
24
+ }
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ use self::defined_activity::DefinedPaymentActivity;
29
29
use self :: random_activity:: { NetworkGraphView , RandomPaymentActivity } ;
30
30
31
31
pub mod cln;
32
+ pub mod clock;
32
33
mod defined_activity;
33
34
pub mod eclair;
34
35
pub mod lnd;
You can’t perform that action at this time.
0 commit comments