File tree Expand file tree Collapse file tree 1 file changed +32
-4
lines changed Expand file tree Collapse file tree 1 file changed +32
-4
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package loop
33import (
44 "context"
55 "fmt"
6+ "strings"
67 "sync"
78 "sync/atomic"
89 "time"
@@ -52,10 +53,37 @@ func newExecutor(cfg *executorConfig) *executor {
5253func (s * executor ) run (mainCtx context.Context ,
5354 statusChan chan <- SwapInfo ) error {
5455
55- blockEpochChan , blockErrorChan , err :=
56- s .lnd .ChainNotifier .RegisterBlockEpochNtfn (mainCtx )
57- if err != nil {
58- return err
56+ var (
57+ err error
58+ blockEpochChan <- chan int32
59+ blockErrorChan <- chan error
60+ )
61+
62+ for {
63+ blockEpochChan , blockErrorChan , err =
64+ s .lnd .ChainNotifier .RegisterBlockEpochNtfn (mainCtx )
65+ if err != nil {
66+ if strings .Contains (err .Error (),
67+ "in the process of starting" ) {
68+
69+ log .Warnf ("LND chain notifier server not " +
70+ "ready yet, retrying with delay" )
71+
72+ // Give chain notifier some time to start and
73+ // try to re-attempt block epoch subscription.
74+ select {
75+ case <- time .After (500 * time .Millisecond ):
76+ continue
77+
78+ case <- mainCtx .Done ():
79+ return err
80+ }
81+ }
82+
83+ return err
84+ }
85+
86+ break
5987 }
6088
6189 // Before starting, make sure we have an up to date block height.
You can’t perform that action at this time.
0 commit comments