Skip to content

Commit

Permalink
Fix some typos blockInfo-> block
Browse files Browse the repository at this point in the history
Map -> List
  • Loading branch information
nkysg committed Jun 20, 2024
1 parent 1991b4b commit e340e43
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected void executeInternal(JobExecutionContext jobExecutionContext) {
long headHeight = chainHeader.getHeight();
long bulkNumber = Math.min(headHeight - localBlockOffset.getBlockHeight(), bulkSize);
int index = 1;
Map<String, Block> blockMap = new HashMap<>();
List<Block> blockList = new ArrayList<>();
while (index <= bulkNumber) {
long currentBlockHeight = localBlockOffset.getBlockHeight() + index;

Expand All @@ -98,14 +98,14 @@ protected void executeInternal(JobExecutionContext jobExecutionContext) {
return;
}

blockMap.put(block.getHeader().getBlockHash(), block);
blockList.add(block);

//update current header
currentHandleHeader = block.getHeader();
index++;
logger.info("add block: {}", block.getHeader());
}
inspectorHandler.upsertDagInfoFromBlocks(new ArrayList<>(blockMap.values()));
inspectorHandler.upsertDagInfoFromBlocks(blockList);

// Update offset
localBlockOffset.setBlockHeight(currentHandleHeader.getHeight());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,20 @@ public void upsertDagInfoFromBlocks(List<Block> blockList) throws IOException, J
);

// Build block node data
blockList.forEach(blockInfo -> {
String currentBlockHash = blockInfo.getHeader().getBlockHash();
blockList.forEach(block -> {
String currentBlockHash = block.getHeader().getBlockHash();
DagInspectorBlock dagBlock = dagBlockMap.get(currentBlockHash);
if (dagBlock == null) {
try {
BlockGhostdagData ghostdagData = blockRPCClient.getBlockGhostdagData(currentBlockHash);
dagBlock = new DagInspectorBlock();
dagBlock.setBlockHash(currentBlockHash);
dagBlock.setTimestamp(blockInfo.getHeader().getTimestamp());
dagBlock.setTimestamp(block.getHeader().getTimestamp());
dagBlock.setColor(NODE_COLOR_GRAY);
dagBlock.setDaaScore(ghostdagData.getBlueScore());
dagBlock.setHeight(blockInfo.getHeader().getHeight());
dagBlock.setHeight(block.getHeader().getHeight());
dagBlock.setSelectedParentHash(ghostdagData.getSelectedParent());
dagBlock.setParentIds(blockInfo.getHeader().getParentsHash());
dagBlock.setParentIds(block.getHeader().getParentsHash());
// Block is the virtual selected parent chain because the list read from block height
dagBlock.setInVirtualSelectedParentChain(true);

Expand Down Expand Up @@ -148,7 +148,7 @@ List<DagInspectorEdge> buildEdgeDataFromDagBlockDataMaybeUpate(
DagInspectorBlock parentDagBlock = dagBlockMap.get(parentHash);
if (parentDagBlock == null) {
logger.info("Parent block not found: {} ", parentHash);
parentDagBlock = getDagInspectorBlockInfoFromHash(parentHash, heightGroupList);
parentDagBlock = getDagInspectorBlockFromHash(parentHash, heightGroupList);

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


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

Block blockInfo = blockRPCClient.getBlockByHash(blockHash);
Block block = blockRPCClient.getBlockByHash(blockHash);
BlockGhostdagData blockGhostdagData = blockRPCClient.getBlockGhostdagData(blockHash);
DagInspectorBlock dagBlock = new DagInspectorBlock();

Long blockHeight = blockInfo.getHeader().getHeight();
Long blockHeight = block.getHeader().getHeight();

dagBlock.setBlockHash(blockHash);
dagBlock.setTimestamp(blockInfo.getHeader().getTimestamp());
dagBlock.setTimestamp(block.getHeader().getTimestamp());
dagBlock.setColor(NODE_COLOR_GRAY);
dagBlock.setDaaScore(blockGhostdagData.getBlueScore());
dagBlock.setHeight(blockInfo.getHeader().getHeight());
dagBlock.setHeight(block.getHeader().getHeight());
dagBlock.setSelectedParentHash(blockGhostdagData.getSelectedParent());
dagBlock.setParentIds(blockInfo.getHeader().getParentsHash());
dagBlock.setParentIds(block.getHeader().getParentsHash());
dagBlock.setInVirtualSelectedParentChain(false);

// Height group list index
Expand All @@ -350,7 +350,7 @@ protected DagInspectorBlock getDagInspectorBlockInfoFromHash(

logger.info("Get block info from hash: {}, height: {}, heightGroupIndex: {}",
blockHash,
blockInfo.getHeader().getHeight(),
block.getHeader().getHeight(),
dagBlock.getHeightGroupIndex()
);
return dagBlock;
Expand Down

0 comments on commit e340e43

Please sign in to comment.