Skip to content

Commit a44dc6a

Browse files
committed
added more time for hnsd to start
1 parent 08938d1 commit a44dc6a

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

sync/hnsd.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ func contains(s []BlockInfo, str string) bool {
2828
}
2929

3030
const (
31-
BlocksToStore = 40
32-
dnsServer = "127.0.0.1"
33-
dnsPort = "5350"
34-
dnsAddress = dnsServer + ":" + dnsPort
35-
qtype = "TXT"
36-
qclass = "HS"
37-
qname = "synced.chain.hnsd"
38-
timeToNotify = 2
31+
BlocksToStore = 40
32+
dnsServer = "127.0.0.1"
33+
dnsPort = "5350"
34+
dnsAddress = dnsServer + ":" + dnsPort
35+
qtype = "TXT"
36+
qclass = "HS"
37+
qname = "synced.chain.hnsd"
38+
timeToNotify = 2
39+
secondsForHNSD = 5
3940
)
4041

4142
var (
@@ -124,10 +125,16 @@ func GetRoots(pathToExecutable string, confPath string, pathToCheckpoint string)
124125
log.Fatalf("Error starting command: %v", err)
125126
}
126127

127-
time.Sleep(1 * time.Second) //time hnsd needs to start running
128-
if err := CheckHNSDVersion(); err != nil {
129-
cancel()
130-
log.Fatalf("hnsd version is not compatible with SANE or cannot be run properly: %v", err)
128+
time.Sleep(100 * time.Millisecond) //wait 0.1 should suffice for the most of the computers
129+
for i := 1; i <= secondsForHNSD; i++ {
130+
if err := CheckHNSDVersion(); err == nil {
131+
break
132+
}
133+
if i == secondsForHNSD {
134+
cancel()
135+
log.Fatalf("hnsd version is not compatible with SANE or cannot be run properly: %v", err)
136+
}
137+
time.Sleep(1000 * time.Millisecond) //time hnsd needs to start running
131138
}
132139

133140
slidingWindow := make([]BlockInfo, 0, BlocksToStore)

0 commit comments

Comments
 (0)