@@ -44,13 +44,16 @@ pub struct Loader {
4444 pub daemon_started : bool ,
4545 pub internal_bitcoind : Option < Bitcoind > ,
4646 pub waiting_daemon_bitcoind : bool ,
47+ pub receiver : crossbeam_channel:: Receiver < String > ,
4748
4849 step : Step ,
4950}
5051
5152pub enum Step {
5253 Connecting ,
53- StartingDaemon ,
54+ StartingDaemon {
55+ liana_logs : String ,
56+ } ,
5457 Syncing {
5558 daemon : Arc < dyn Daemon + Sync + Send > ,
5659 progress : f64 ,
@@ -77,7 +80,7 @@ pub enum Message {
7780 ) ,
7881 Started ( Result < ( Arc < dyn Daemon + Sync + Send > , Option < Bitcoind > ) , Error > ) ,
7982 Loaded ( Result < Arc < dyn Daemon + Sync + Send > , Error > ) ,
80- BitcoindLog ( Option < String > ) ,
83+ LogMessage ( Option < String > ) ,
8184 Failure ( DaemonError ) ,
8285}
8386
@@ -87,6 +90,7 @@ impl Loader {
8790 gui_config : GUIConfig ,
8891 network : bitcoin:: Network ,
8992 internal_bitcoind : Option < Bitcoind > ,
93+ receiver : crossbeam_channel:: Receiver < String > ,
9094 ) -> ( Self , Command < Message > ) {
9195 let path = gui_config
9296 . daemon_rpc_path
@@ -102,6 +106,7 @@ impl Loader {
102106 daemon_started : false ,
103107 internal_bitcoind,
104108 waiting_daemon_bitcoind : false ,
109+ receiver,
105110 } ,
106111 Command :: perform ( connect ( path) , Message :: Loaded ) ,
107112 )
@@ -128,7 +133,9 @@ impl Loader {
128133 | Error :: Daemon ( DaemonError :: Transport ( Some ( ErrorKind :: ConnectionRefused ) , _) )
129134 | Error :: Daemon ( DaemonError :: Transport ( Some ( ErrorKind :: NotFound ) , _) ) => {
130135 if let Some ( daemon_config_path) = self . gui_config . daemon_config_path . clone ( ) {
131- self . step = Step :: StartingDaemon ;
136+ self . step = Step :: StartingDaemon {
137+ liana_logs : String :: new ( ) ,
138+ } ;
132139 self . daemon_started = true ;
133140 self . waiting_daemon_bitcoind = true ;
134141 return Command :: perform (
@@ -153,7 +160,11 @@ impl Loader {
153160 }
154161
155162 fn on_log ( & mut self , log : Option < String > ) -> Command < Message > {
156- if let Step :: Syncing { bitcoind_logs, .. } = & mut self . step {
163+ if let Step :: StartingDaemon { liana_logs } = & mut self . step {
164+ if let Some ( l) = log {
165+ * liana_logs = l;
166+ }
167+ } else if let Step :: Syncing { bitcoind_logs, .. } = & mut self . step {
157168 if let Some ( l) = log {
158169 * bitcoind_logs = l;
159170 }
@@ -254,14 +265,15 @@ impl Loader {
254265 self . gui_config . clone ( ) ,
255266 self . network ,
256267 self . internal_bitcoind . clone ( ) ,
268+ self . receiver . clone ( ) ,
257269 ) ;
258270 * self = loader;
259271 cmd
260272 }
261273 Message :: Started ( res) => self . on_start ( res) ,
262274 Message :: Loaded ( res) => self . on_load ( res) ,
263275 Message :: Syncing ( res) => self . on_sync ( res) ,
264- Message :: BitcoindLog ( log) => self . on_log ( log) ,
276+ Message :: LogMessage ( log) => self . on_log ( log) ,
265277 Message :: Synced ( Err ( e) ) => {
266278 self . step = Step :: Error ( Box :: new ( e) ) ;
267279 Command :: none ( )
@@ -275,6 +287,16 @@ impl Loader {
275287 }
276288
277289 pub fn subscription ( & self ) -> Subscription < Message > {
290+ if let Step :: StartingDaemon { .. } = self . step {
291+ return iced:: subscription:: unfold ( 1 , self . receiver . clone ( ) , move |recv| async {
292+ let log_msg = match recv. recv ( ) {
293+ Ok ( msg) => msg,
294+ Err ( e) => e. to_string ( ) ,
295+ } ;
296+
297+ ( Message :: LogMessage ( Some ( log_msg) ) , recv)
298+ } ) ;
299+ }
278300 if let Some ( Some ( bitcoind_stdout) ) =
279301 self . internal_bitcoind . as_ref ( ) . map ( |b| b. stdout . clone ( ) )
280302 {
@@ -284,8 +306,8 @@ impl Loader {
284306 let mut s = std:: io:: BufReader :: new ( s. deref_mut ( ) ) ;
285307 let mut buffer = String :: new ( ) ;
286308 match s. read_line ( & mut buffer) {
287- Err ( e) => Message :: BitcoindLog ( Some ( e. to_string ( ) ) ) ,
288- Ok ( _) => Message :: BitcoindLog ( Some ( buffer) ) ,
309+ Err ( e) => Message :: LogMessage ( Some ( e. to_string ( ) ) ) ,
310+ Ok ( _) => Message :: LogMessage ( Some ( buffer) ) ,
289311 }
290312 } ;
291313 ( msg, stdout)
@@ -342,12 +364,13 @@ pub enum ViewMessage {
342364
343365pub fn view ( step : & Step ) -> Element < ViewMessage > {
344366 match & step {
345- Step :: StartingDaemon => cover (
367+ Step :: StartingDaemon { liana_logs } => cover (
346368 None ,
347369 Column :: new ( )
348370 . width ( Length :: Fill )
349371 . push ( ProgressBar :: new ( 0.0 ..=1.0 , 0.0 ) . width ( Length :: Fill ) )
350- . push ( text ( "Starting daemon..." ) ) ,
372+ . push ( text ( "Starting daemon..." ) )
373+ . push ( p2_regular ( liana_logs) . style ( color:: GREY_3 ) ) ,
351374 ) ,
352375 Step :: Connecting => cover (
353376 None ,
0 commit comments