Skip to content

Commit

Permalink
fix detecting empty response
Browse files Browse the repository at this point in the history
  • Loading branch information
ramilexe committed Jan 26, 2021
1 parent 51855db commit 286c89b
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions pkg/qlparser/ethHeaderCidByBlockNumber.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,27 @@ func IsHaveEthHeaderCidByBlockNumberData(data []byte) (bool, error) {
return true, err
}

edges := json.Get("data", "ethHeaderCidByBlockNumber", "edges")
if edges == nil {
header := json.Get("data", "ethHeaderCidByBlockNumber")
if header == nil {
return true, nil
}

aEdges, err := edges.Array()
// can contain nodes or header
var arrValue *fastjson.Value
nodes := header.Get("nodes")
if nodes == nil {
// check edges
edges := header.Get("edges")
if edges == nil {
return true, nil
}

arrValue = edges
} else {
arrValue = nodes
}

aEdges, err := arrValue.Array()
if err != nil {
return true, err
}
Expand Down

0 comments on commit 286c89b

Please sign in to comment.