@@ -66,8 +66,8 @@ function prepareForkchoiceUpdatedCall(fork_choice, headBlockHash, fork) {
66
66
const finalizedCheckpointRoot = fork_choice . finalized_checkpoint . root ;
67
67
const forkChoiceNodes = fork_choice . fork_choice_nodes ;
68
68
69
- const safeBlockHash = calculateSafeBlockHash ( justifiedCheckpointRoot , forkChoiceNodes ) ;
70
- const finalizedBlockHash = calculateFinalizedBlockHash ( finalizedCheckpointRoot , forkChoiceNodes ) ;
69
+ const safeBlockHash = executionBlockHashLookup ( justifiedCheckpointRoot , forkChoiceNodes ) ;
70
+ const finalizedBlockHash = executionBlockHashLookup ( finalizedCheckpointRoot , forkChoiceNodes ) ;
71
71
72
72
switch ( fork ) {
73
73
case 'capella' :
@@ -95,23 +95,11 @@ function prepareForkchoiceUpdatedCall(fork_choice, headBlockHash, fork) {
95
95
}
96
96
}
97
97
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 ) ;
101
100
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 ;
115
103
}
116
104
117
105
return null ;
0 commit comments