Skip to content

Commit b800122

Browse files
committed
Extra checks for block hash when batch requesting block and logs.
1 parent e222e55 commit b800122

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@ class BlockMonitor extends EventEmitter {
7878
const block = results.data[0].result;
7979
const logs = results.data[1].result;
8080

81+
if (block["hash"] === undefined) {
82+
throw new Error("missing hash in response for getBlock request of the [getBlock, GetPastLogs] batch request");
83+
}
84+
for (const logEntry of logs) {
85+
if (logEntry["blockHash"] === undefined) {
86+
throw new Error("missing blockHash in response for GetPastLogs request of the [getBlock, GetPastLogs] batch request");
87+
}
88+
else if (logEntry["blockHash"] != block["hash"]) {
89+
throw new Error("mismatched hashes in response of [getBlock, GetPastLogs] batch request");
90+
}
91+
}
92+
8193
block.logs = logs;
8294
//console.log("RPC batch result:" + JSON.stringify(block));
8395
return block;

0 commit comments

Comments
 (0)