Skip to content

Commit

Permalink
More checks for corner cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
yarkinwho committed Dec 8, 2023
1 parent b800122 commit d8e2a14
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions peripherals/eos-evm-ws-proxy/block-monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,17 @@ class BlockMonitor extends EventEmitter {
const block = results.data[0].result;
const logs = results.data[1].result;

if (block["hash"] === undefined) {
if (!block || !block["hash"]) {
throw new Error("missing hash in response for getBlock request of the [getBlock, GetPastLogs] batch request");
}
if (!Array.isArray(logs)) {
throw new Error("invalid logs in response for GetPastLogs request of the [getBlock, GetPastLogs] batch request");
}
for (const logEntry of logs) {
if (logEntry["blockHash"] === undefined) {
if (!logEntry["blockHash"]) {
throw new Error("missing blockHash in response for GetPastLogs request of the [getBlock, GetPastLogs] batch request");
}
else if (logEntry["blockHash"] != block["hash"]) {
else if (logEntry["blockHash"] !== block["hash"]) {
throw new Error("mismatched hashes in response of [getBlock, GetPastLogs] batch request");
}
}
Expand Down

0 comments on commit d8e2a14

Please sign in to comment.