Skip to content

Commit

Permalink
[dag block scan-api] fixed if getBlocksByHeight throw exception
Browse files Browse the repository at this point in the history
  • Loading branch information
welbon committed Jun 26, 2024
1 parent 94e4f3e commit 62b1f1d
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.starcoin.scan.service;

import com.alibaba.fastjson.JSONObject;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
Expand Down Expand Up @@ -105,7 +106,7 @@ public DIBlocksAndEdgesAndHeightGroupsVo getHead(String network, Long heightDiff
* @param endHeight
* @return
*/
private List<DagInspectorBlock> getBlockList(String network, Long startHeight, Long endHeight) throws IOException {
private List<DagInspectorBlock> getBlockList(String network, Long startHeight, Long endHeight) throws ElasticsearchException, IOException {
SearchRequest searchRequest = new SearchRequest(getIndex(network, Constant.DAG_INSPECTOR_BLOCK));
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
sourceBuilder.query(QueryBuilders.boolQuery().must(QueryBuilders.rangeQuery("height").gte(startHeight).lte(endHeight)));
Expand Down Expand Up @@ -251,7 +252,7 @@ public List<DagInspectorBlock> getBlocksByHeight(String network, Long height) {
SearchResponse searchResponse;
try {
searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
} catch (IOException e) {
} catch (IOException | org.elasticsearch.ElasticsearchStatusException e) {
logger.error("getBlocksByHeight failed, blockHash: {}", height, e);
return null;
}
Expand Down

0 comments on commit 62b1f1d

Please sign in to comment.