From 0813d73e975d7c2352b6fe4930966bfaa287dad4 Mon Sep 17 00:00:00 2001 From: mdr0id Date: Mon, 10 Jun 2019 21:14:31 -0700 Subject: [PATCH] Add initial error handling for condition for zcashd down --- cmd/ingest/main.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/ingest/main.go b/cmd/ingest/main.go index 0b20ef8..a1c613f 100644 --- a/cmd/ingest/main.go +++ b/cmd/ingest/main.go @@ -126,19 +126,30 @@ func main() { "error": err, }).Warn("invalid current height read from local db storage") } - + + timeout_count := 0 // Start listening for new blocks for { block, err := getBlock(rpcClient, height) - if err != nil{ + if err != nil { log.WithFields(logrus.Fields{ "height": height, "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 { handleBlock(db, block) height++ + if timeout_count > 0 { + timeout_count-- + } //TODO store block current/prev hash for formal reorg } else { //TODO implement blocknotify to minimize polling on corner cases