Add initial error handling for condition for zcashd down
This commit is contained in:
parent
d1e49493b0
commit
0813d73e97
|
@ -127,18 +127,29 @@ func main() {
|
||||||
}).Warn("invalid current height read from local db storage")
|
}).Warn("invalid current height read from local db storage")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timeout_count := 0
|
||||||
// Start listening for new blocks
|
// Start listening for new blocks
|
||||||
for {
|
for {
|
||||||
block, err := getBlock(rpcClient, height)
|
block, err := getBlock(rpcClient, height)
|
||||||
if err != nil{
|
if err != nil {
|
||||||
log.WithFields(logrus.Fields{
|
log.WithFields(logrus.Fields{
|
||||||
"height": height,
|
"height": height,
|
||||||
"error": err,
|
"error": err,
|
||||||
}).Fatal("error with getblock")
|
}).Warn("error with getblock")
|
||||||
|
timeout_count++
|
||||||
|
if timeout_count == 3 {
|
||||||
|
log.WithFields(logrus.Fields{
|
||||||
|
"timeouts": timeout_count,
|
||||||
|
}).Warn("unable to issue RPC call to zcashd node 3 times")
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if block != nil {
|
if block != nil {
|
||||||
handleBlock(db, block)
|
handleBlock(db, block)
|
||||||
height++
|
height++
|
||||||
|
if timeout_count > 0 {
|
||||||
|
timeout_count--
|
||||||
|
}
|
||||||
//TODO store block current/prev hash for formal reorg
|
//TODO store block current/prev hash for formal reorg
|
||||||
} else {
|
} else {
|
||||||
//TODO implement blocknotify to minimize polling on corner cases
|
//TODO implement blocknotify to minimize polling on corner cases
|
||||||
|
|
Loading…
Reference in New Issue