Skip to content

Commit 09a8449

Browse files
committed
cleanups
1 parent 7eba30c commit 09a8449

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

engineApi.js

+6-18
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ function prepareForkchoiceUpdatedCall(fork_choice, headBlockHash, fork) {
6666
const finalizedCheckpointRoot = fork_choice.finalized_checkpoint.root;
6767
const forkChoiceNodes = fork_choice.fork_choice_nodes;
6868

69-
const safeBlockHash = calculateSafeBlockHash(justifiedCheckpointRoot, forkChoiceNodes);
70-
const finalizedBlockHash = calculateFinalizedBlockHash(finalizedCheckpointRoot, forkChoiceNodes);
69+
const safeBlockHash = executionBlockHashLookup(justifiedCheckpointRoot, forkChoiceNodes);
70+
const finalizedBlockHash = executionBlockHashLookup(finalizedCheckpointRoot, forkChoiceNodes);
7171

7272
switch (fork) {
7373
case 'capella':
@@ -95,23 +95,11 @@ function prepareForkchoiceUpdatedCall(fork_choice, headBlockHash, fork) {
9595
}
9696
}
9797

98-
// Helper function to calculate the safeBlockHash
99-
function calculateSafeBlockHash(justifiedCheckpointRoot, forkChoiceNodes) {
100-
const safeBlockNode = forkChoiceNodes.find(node => node.block_root === justifiedCheckpointRoot);
98+
function executionBlockHashLookup(beaconBlockRoot, forkChoiceNodes) {
99+
const node = forkChoiceNodes.find(node => node.block_root === beaconBlockRoot);
101100

102-
if (safeBlockNode) {
103-
return safeBlockNode.execution_block_hash;
104-
}
105-
106-
return null;
107-
}
108-
109-
// Helper function to calculate the finalizedBlockHash
110-
function calculateFinalizedBlockHash(finalizedCheckpointRoot, forkChoiceNodes) {
111-
const finalizedBlockNode = forkChoiceNodes.find(node => node.block_root === finalizedCheckpointRoot);
112-
113-
if (finalizedBlockNode) {
114-
return finalizedBlockNode.execution_block_hash;
101+
if (node) {
102+
return node.execution_block_hash;
115103
}
116104

117105
return null;

jsonrpc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function doJsonrpcCall(endpoint, engineCall, jwtToken) {
1515
'Authorization': `Bearer ${jwtToken}`
1616
};
1717

18-
console.error(`[${endpoint}] calling ${engineCall.method}`);
18+
console.log(`[${endpoint}] calling ${engineCall.method}`);
1919

2020
const response = await axios.post(endpoint, request, { headers });
2121

0 commit comments

Comments
 (0)