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

feat: #48 Added onParsingError call back to listen to any block parsing error #53

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,17 @@ private void onReceiveBlocks(MsgBlock message) {
} catch (Exception e) {
errorBlks++;
log.error("Error in parsing", e);
Array headerArray = (Array) ((Array)array.getDataItems().get(1)).getDataItems().get(0);
BlockHeader blockHeader = BlockHeaderSerializer.INSTANCE.getBlockHeaderFromHeaderArray(headerArray);
log.error("BlockHeader >> Block No: " + blockHeader.getHeaderBody().getBlockNumber() +", Slot: " + blockHeader.getHeaderBody().getSlot());

//Catch exception to avoid exception propagation
try {
Array headerArray = (Array) ((Array) array.getDataItems().get(1)).getDataItems().get(0);
BlockHeader blockHeader = BlockHeaderSerializer.INSTANCE.getBlockHeaderFromHeaderArray(headerArray);
log.error("BlockHeader >> Block No: " + blockHeader.getHeaderBody().getBlockNumber() + ", Slot: " + blockHeader.getHeaderBody().getSlot());
} catch (Exception e1) {
log.error("Error in parsing block header", e1);
}

getAgentListeners().stream().forEach(blockfetchAgentListener -> blockfetchAgentListener.onParsingError(e));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ default void byronEbBlockFound(ByronEbBlock byronEbBlock) {

}

default void onParsingError(Exception e) {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ default void intersactFound(Tip tip, Point point) {}
default void intersactNotFound(Tip tip) {}

default void onDisconnect() {}

default void onParsingError(Exception e) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,9 @@ public void noBlockFound(Point from, Point to) {
public void onDisconnect() {
blockChainDataListener.onDisconnect();
}

@Override
public void onParsingError(Exception e) {
blockChainDataListener.onParsingError(e);
}
}
Loading