Skip to content

Commit

Permalink
[dag inspector] Fixed the error of block field name mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
welbon committed Jun 25, 2024
1 parent c66a0fb commit 9533817
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 18 deletions.
10 changes: 10 additions & 0 deletions docker-compose/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 如何构建本地环境

## 1. 安装 Docker
## 2. 安装 Docker Compose
## 3. 运行以下命令
```bash
docker-compose up
```
## 4. 访问 http://localhost:8080
```
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ List<DagInspectorEdge> buildEdgeDataFromDagBlockDataMaybeUpate(
DagInspectorBlock parentDagBlock = dagBlockMap.get(parentHash);
if (parentDagBlock == null) {
logger.info("Parent block not found: {} ", parentHash);
parentDagBlock = getDagInspectorBlockInfoFromHash(parentHash, heightGroupList);
parentDagBlock = getDagInspectorBlockInfoFromHash(parentHash, heightGroupList, false);

// Put into buffer list
newDagBlocks.add(parentDagBlock);
Expand Down Expand Up @@ -324,7 +324,8 @@ private List<DagInspectorHeightGroup> getGroupHeightSizeFromStorage(List<Long> h

protected DagInspectorBlock getDagInspectorBlockInfoFromHash(
String blockHash,
List<DagInspectorHeightGroup> heightGroupList
List<DagInspectorHeightGroup> heightGroupList,
boolean isSelectedParentChain
) throws JSONRPC2SessionException {

Block blockInfo = blockRPCClient.getBlockByHash(blockHash);
Expand All @@ -340,7 +341,7 @@ protected DagInspectorBlock getDagInspectorBlockInfoFromHash(
dagBlock.setHeight(blockInfo.getHeader().getHeight());
dagBlock.setSelectedParentHash(blockGhostdagData.getSelectedParent());
dagBlock.setParentIds(blockInfo.getHeader().getParentsHash());
dagBlock.setInVirtualSelectedParentChain(false);
dagBlock.setInVirtualSelectedParentChain(isSelectedParentChain);

// Height group list index
Integer groupSize = getHeightGroupSizeOrDefault(heightGroupList, blockHeight, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ public BlockVo getBlockByHeight(
@PathVariable("network") String network,
@PathVariable("height") long height
) {
BlockVo blockVo = BlockVo.from(blockService.getBlockByHeight(network, height));
Block block = blockService.getBlockByHeight(network, height);
if (block == null) {
return new BlockVo();
}
BlockVo blockVo = BlockVo.from(block);
List<DagInspectorBlock> dagBlocks = dagInspectorService.getBlocksByHeight(network, height);
if (dagBlocks == null || dagBlocks.isEmpty()) {
return blockVo;
Expand All @@ -71,8 +75,8 @@ public BlockVo getBlockByHeight(
.filter(dagBlock -> dagBlock.getBlockHash().equals(blockVo.getId()))
.findFirst().ifPresent(dagBlock -> {
blockVo.setDaaScore(dagBlock.getDaaScore());
blockVo.setMergeSetBlueIds(dagBlock.getMergeSetBlueIds());
blockVo.setHeightGroupIndex(dagBlock.getHeightGroupIndex());
blockVo.setMergedBlueset(dagBlock.getMergeSetBlueIds());
blockVo.setHeightgroupIndex(dagBlock.getHeightGroupIndex());
});
return blockVo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@
import java.util.List;

public class BlockVo extends Block {

@JSONField(name = "daa_score")
@JsonProperty("daa_score")
private Long daaScore;

private Integer heightGroupIndex;
@JSONField(name = "heightgroup_index")
@JsonProperty("heightgroup_index")
private Integer heightgroupIndex;

List<String> mergeSetBlueIds;
@JSONField(name = "merged_blueset")
@JsonProperty("merged_blueset")
List<String> mergedBlueset;

public Long getDaaScore() {
return daaScore;
Expand All @@ -22,20 +29,20 @@ public void setDaaScore(Long daaScore) {
this.daaScore = daaScore;
}

public Integer getHeightGroupIndex() {
return heightGroupIndex;
public Integer getHeightgroupIndex() {
return heightgroupIndex;
}

public void setHeightGroupIndex(Integer heightGroupIndex) {
this.heightGroupIndex = heightGroupIndex;
public void setHeightgroupIndex(Integer heightgroupIndex) {
this.heightgroupIndex = heightgroupIndex;
}

public List<String> getMergeSetBlueIds() {
return mergeSetBlueIds;
public List<String> getMergedBlueset() {
return mergedBlueset;
}

public void setMergeSetBlueIds(List<String> mergeSetBlueIds) {
this.mergeSetBlueIds = mergeSetBlueIds;
public void setMergedBlueset(List<String> mergedBlueset) {
this.mergedBlueset = mergedBlueset;
}

public static BlockVo from(Block block) {
Expand All @@ -49,8 +56,8 @@ public static BlockVo from(Block block) {
blockVo.setBody(block.getBody());

blockVo.setDaaScore(0L);
blockVo.setHeightGroupIndex(0);
blockVo.setMergeSetBlueIds(new ArrayList<>());
blockVo.setHeightgroupIndex(0);
blockVo.setMergedBlueset(new ArrayList<>());

return blockVo;
}
Expand Down

0 comments on commit 9533817

Please sign in to comment.