Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blockwatch: Handle both Parity and Geth "unknown block" errors gracefully #285

Merged
merged 1 commit into from Jul 19, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -227,7 +227,7 @@ func (w *Watcher) buildCanonicalChain(nextHeader *meshdb.MiniHeader, events []*E
// a block header might be returned, but when fetching it's logs, an "unknown block" error is
// returned. This is expected to happen sometimes, and we simply return the events gathered so
// far and pick back up where we left off on the next polling interval.
if err.Error() == "unknown block" {
if isUnknownBlockErr(err) {
log.WithFields(log.Fields{
"nextHeader": nextHeader,
}).Trace("failed to get logs for block")
@@ -277,7 +277,7 @@ func (w *Watcher) buildCanonicalChain(nextHeader *meshdb.MiniHeader, events []*E
// a block header might be returned, but when fetching it's logs, an "unknown block" error is
// returned. This is expected to happen sometimes, and we simply return the events gathered so
// far and pick back up where we left off on the next polling interval.
if err.Error() == "unknown block" {
if isUnknownBlockErr(err) {
log.WithFields(log.Fields{
"nextHeader": nextHeader,
}).Trace("failed to get logs for block")
@@ -598,3 +598,15 @@ func (w *Watcher) filterLogsRecurisively(from, to int, allLogs []types.Log) ([]t
allLogs = append(allLogs, logs...)
return allLogs, nil
}

func isUnknownBlockErr(err error) bool {
// Geth error
if err.Error() == "unknown block" {
return true
}
// Parity error
if err.Error() == "One of the blocks specified in filter (fromBlock, toBlock or blockHash) cannot be found" {
return true
}
return false
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.