@@ -244,37 +244,19 @@ func processSlot(client *http.Client, cfg Config, slot uint64) {
244244 },
245245 }
246246
247- // 3 . Fetch Block from both
247+ // 1 . Fetch Block from Ref ONLY first (to get signatures and baseline)
248248 refBlock , refLat , refErr := callRPC (client , cfg .RefRPC , "getBlock" , params )
249- targetBlock , targetLat , targetErr := callRPC (client , cfg .TargetRPC , "getBlock" , params )
250-
251- // Log Slot Header with Latency
252- logLatency (fmt .Sprintf ("📦 SLOT %d" , slot ), refLat , targetLat )
253249
254- // Handle availability issues
255- if refErr != nil || targetErr != nil {
256- if refErr != nil && targetErr != nil {
257- if cfg .Verbose {
258- log .Printf (" ⚠️ Skipped (both missing)" )
259- }
260- return
261- }
262- log .Printf (" ❌ FETCH ERROR | Ref: %v | Target: %v" , errorStr (refErr ), errorStr (targetErr ))
250+ if refErr != nil {
251+ // If Ref failed, we can't get signatures to check Txs, but we should still try to check Target Block existence?
252+ // Or just fail the slot. Let's fail the slot for consistency with previous logic which required both.
253+ // However, to strictly check Target Block latency independently, we could fetch it, but we have no Ref to compare.
254+ // Let's abort if Ref fails.
255+ log .Printf (" ❌ Ref Fetch Failed: %v" , refErr )
263256 return
264257 }
265258
266- // 4. Compare Block Data
267- var refData , targetData interface {}
268- json .Unmarshal (refBlock , & refData )
269- json .Unmarshal (targetBlock , & targetData )
270-
271- if ! reflect .DeepEqual (refData , targetData ) {
272- compareJSON (refBlock , targetBlock , fmt .Sprintf ("Block %d" , slot ), cfg .StopOnDiff )
273- } else if cfg .Verbose {
274- log .Printf (" ✅ Content Match" )
275- }
276-
277- // Extract signatures
259+ // 2. Extract signatures from Ref Block
278260 var blockStruct struct {
279261 Transactions []struct {
280262 Transaction struct {
@@ -283,35 +265,56 @@ func processSlot(client *http.Client, cfg Config, slot uint64) {
283265 } `json:"transactions"`
284266 }
285267
286- if err := json .Unmarshal (targetBlock , & blockStruct ); err != nil {
287- log .Printf (" ❌ Failed to parse block structure: %v" , err )
268+ if err := json .Unmarshal (refBlock , & blockStruct ); err != nil {
269+ log .Printf (" ❌ Failed to parse ref block structure: %v" , err )
288270 return
289271 }
290272
291273 sigsToCheck := []string {}
292274 txCount := len (blockStruct .Transactions )
293275
294- if txCount == 0 {
295- return
296- }
297-
298- perm := securePerm (txCount )
299- limit := cfg .MaxTxsToCheck
300- if limit > txCount {
301- limit = txCount
302- }
276+ if txCount > 0 {
277+ perm := securePerm (txCount )
278+ limit := cfg .MaxTxsToCheck
279+ if limit > txCount {
280+ limit = txCount
281+ }
303282
304- for i := 0 ; i < limit ; i ++ {
305- tx := blockStruct.Transactions [perm [i ]]
306- if len (tx .Transaction .Signatures ) > 0 {
307- sigsToCheck = append (sigsToCheck , tx .Transaction .Signatures [0 ])
283+ for i := 0 ; i < limit ; i ++ {
284+ tx := blockStruct.Transactions [perm [i ]]
285+ if len (tx .Transaction .Signatures ) > 0 {
286+ sigsToCheck = append (sigsToCheck , tx .Transaction .Signatures [0 ])
287+ }
308288 }
309289 }
310290
311- // 5 . Check Transactions
291+ // 3 . Check Transactions (Target "cold" read - assuming block hasn't been fetched yet)
312292 for _ , sig := range sigsToCheck {
313293 compareTransaction (client , cfg , sig )
314294 }
295+
296+ // 4. Fetch Block from Target (now that Txs are checked)
297+ targetBlock , targetLat , targetErr := callRPC (client , cfg .TargetRPC , "getBlock" , params )
298+
299+ // Log Slot Header with Latency (now that we have both)
300+ logLatency (fmt .Sprintf ("📦 SLOT %d" , slot ), refLat , targetLat )
301+
302+ // Handle availability issues
303+ if targetErr != nil {
304+ log .Printf (" ❌ Target Fetch Failed: %v" , targetErr )
305+ return
306+ }
307+
308+ // 5. Compare Block Data
309+ var refData , targetData interface {}
310+ json .Unmarshal (refBlock , & refData )
311+ json .Unmarshal (targetBlock , & targetData )
312+
313+ if ! reflect .DeepEqual (refData , targetData ) {
314+ compareJSON (refBlock , targetBlock , fmt .Sprintf ("Block %d" , slot ), cfg .StopOnDiff )
315+ } else if cfg .Verbose {
316+ log .Printf (" ✅ Content Match" )
317+ }
315318}
316319
317320func compareTransaction (client * http.Client , cfg Config , signature string ) {
0 commit comments