Skip to content

Commit d8e2a14

Browse files
committed
More checks for corner cases.
1 parent b800122 commit d8e2a14

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

peripherals/eos-evm-ws-proxy/block-monitor.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,17 @@ class BlockMonitor extends EventEmitter {
7878
const block = results.data[0].result;
7979
const logs = results.data[1].result;
8080

81-
if (block["hash"] === undefined) {
81+
if (!block || !block["hash"]) {
8282
throw new Error("missing hash in response for getBlock request of the [getBlock, GetPastLogs] batch request");
8383
}
84+
if (!Array.isArray(logs)) {
85+
throw new Error("invalid logs in response for GetPastLogs request of the [getBlock, GetPastLogs] batch request");
86+
}
8487
for (const logEntry of logs) {
85-
if (logEntry["blockHash"] === undefined) {
88+
if (!logEntry["blockHash"]) {
8689
throw new Error("missing blockHash in response for GetPastLogs request of the [getBlock, GetPastLogs] batch request");
8790
}
88-
else if (logEntry["blockHash"] != block["hash"]) {
91+
else if (logEntry["blockHash"] !== block["hash"]) {
8992
throw new Error("mismatched hashes in response of [getBlock, GetPastLogs] batch request");
9093
}
9194
}

0 commit comments

Comments
 (0)