@@ -11,38 +11,41 @@ use nakamoto::client;
11
11
use nakamoto:: common:: bitcoin_hashes:: hex:: FromHex ;
12
12
use nakamoto:: net:: poll:: { Waker , Reactor } ;
13
13
use miniscript:: bitcoin:: hashes:: Hash ;
14
- use miniscript:: bitcoin:: { self , BlockHash } ;
14
+ use miniscript:: bitcoin;
15
15
16
16
use crate :: BitcoindError ;
17
17
use crate :: bitcoin:: BitcoinInterface ;
18
18
19
+ use super :: SyncProgress ;
20
+
19
21
/// Nakamoto client
20
22
pub struct Nakamoto {
21
23
/// Nakamoto handler used interact with the client.
22
24
handler : client:: Handle < Waker > ,
23
25
/// Nakamoto main worked to avoid leave a pending project.
24
- worker : JoinHandle < Result < ( ) , client:: Error > >
25
- network : client:: Network ,
26
+ _worker : JoinHandle < Result < ( ) , client:: Error > > ,
27
+ _network : client:: Network ,
26
28
}
27
29
28
30
impl Nakamoto {
29
31
/// Create a new instance of nakamoto.
30
32
pub fn new ( network : & bitcoin:: Network , connect : & [ net:: SocketAddr ] , data_dir : PathBuf ) -> Result < Self , ( ) > {
31
- let network = client:: Network :: from_str ( & network. to_string ( ) ) . map_err ( |err | ( ) ) ?;
33
+ let network = client:: Network :: from_str ( & network. to_string ( ) ) . map_err ( |_ | ( ) ) ?;
32
34
let mut config = client:: Config :: new ( network) ;
33
35
config. root = data_dir;
34
36
config. connect = connect. to_vec ( ) ;
35
37
config. user_agent = "Liana-Nakamoto-v1" ;
36
38
let client = client:: Client :: < Reactor < net:: TcpStream > > :: new ( ) . unwrap ( ) ;
37
39
let handler = client. handle ( ) ;
38
40
let worker = std:: thread:: spawn ( || client. run ( config) ) ;
39
- Ok ( Self { handler, worker, network } )
41
+ Ok ( Self { handler, _worker : worker, _network : network } )
40
42
}
41
43
42
44
/// Stop the nakamoto node
43
- pub fn stop ( & self ) -> Result < ( ) , BitcoindError > {
44
- self . handler . shutdown ( ) ;
45
- self . worker . join ( ) . map_err ( |err| BitcoindError :: GenericError ) ?;
45
+ #[ allow( dead_code) ]
46
+ pub fn stop ( self ) -> Result < ( ) , BitcoindError > {
47
+ self . handler . shutdown ( ) . map_err ( |_| BitcoindError :: GenericError ) ?;
48
+ let _ = self . _worker . join ( ) . map_err ( |_| BitcoindError :: GenericError ) ?;
46
49
Ok ( ( ) )
47
50
}
48
51
}
@@ -72,15 +75,15 @@ impl BitcoinInterface for Nakamoto {
72
75
}
73
76
74
77
fn common_ancestor ( & self , tip : & crate :: bitcoin:: BlockChainTip ) -> Option < crate :: bitcoin:: BlockChainTip > {
75
- todo ! ( )
78
+ None
76
79
}
77
80
78
81
fn is_in_chain ( & self , tip : & crate :: bitcoin:: BlockChainTip ) -> bool {
79
- unimplemented ! ( )
82
+ true
80
83
}
81
84
82
85
fn block_before_date ( & self , timestamp : u32 ) -> Option < crate :: bitcoin:: BlockChainTip > {
83
- unimplemented ! ( )
86
+ None
84
87
}
85
88
86
89
fn confirmed_coins (
@@ -123,7 +126,7 @@ impl BitcoinInterface for Nakamoto {
123
126
desc : & crate :: descriptors:: LianaDescriptor ,
124
127
timestamp : u32 ,
125
128
) -> Result < ( ) , String > {
126
- // We do not care for the momenet , because we are tracking with nakamoto
129
+ // We do not care for the moment , because we are tracking with nakamoto
127
130
// all the transactions submitted
128
131
Ok ( ( ) )
129
132
}
@@ -158,7 +161,8 @@ impl BitcoinInterface for Nakamoto {
158
161
}
159
162
160
163
fn sync_progress ( & self ) -> super :: SyncProgress {
161
- unimplemented ! ( )
164
+ // FIXME: call tip and try to simulate the bitcoin intergace
165
+ SyncProgress :: new ( 100.0 , 0 , 0 )
162
166
}
163
167
164
168
fn tip_time ( & self ) -> Option < u32 > {
0 commit comments