@@ -361,7 +361,12 @@ func (c *ChainSync) handleRollForward(
361
361
default :
362
362
return errors .New ("unknown type" )
363
363
}
364
- blockEvt := event .New ("chainsync.block" , time .Now (), NewBlockHeaderContext (block .Header ()), NewBlockEvent (block , c .includeCbor ))
364
+ blockEvt := event .New (
365
+ "chainsync.block" ,
366
+ time .Now (),
367
+ NewBlockHeaderContext (block .Header ()),
368
+ NewBlockEvent (block , c .includeCbor ),
369
+ )
365
370
tmpEvents = append (tmpEvents , blockEvt )
366
371
for t , transaction := range block .Transactions () {
367
372
resolvedInputs , err := resolveTransactionInputs (transaction , c )
@@ -371,8 +376,22 @@ func (c *ChainSync) handleRollForward(
371
376
if t < 0 || t > math .MaxUint32 {
372
377
return errors .New ("invalid number of transactions" )
373
378
}
374
- txEvt := event .New ("chainsync.transaction" , time .Now (), NewTransactionContext (block , transaction , uint32 (t ), c .networkMagic ),
375
- NewTransactionEvent (block , transaction , c .includeCbor , resolvedInputs ))
379
+ txEvt := event .New (
380
+ "chainsync.transaction" ,
381
+ time .Now (),
382
+ NewTransactionContext (
383
+ block ,
384
+ transaction ,
385
+ uint32 (t ),
386
+ c .networkMagic ,
387
+ ),
388
+ NewTransactionEvent (
389
+ block ,
390
+ transaction ,
391
+ c .includeCbor ,
392
+ resolvedInputs ,
393
+ ),
394
+ )
376
395
tmpEvents = append (tmpEvents , txEvt )
377
396
}
378
397
updateTip := ochainsync.Tip {
@@ -409,7 +428,13 @@ func (c *ChainSync) handleRollForward(
409
428
c .delayBuffer = slices .Delete (c .delayBuffer , 0 , 1 )
410
429
}
411
430
}
412
- c .updateStatus (updateTip .Point .Slot , updateTip .BlockNumber , hex .EncodeToString (updateTip .Point .Hash ), tip .Point .Slot , hex .EncodeToString (tip .Point .Hash ))
431
+ c .updateStatus (
432
+ updateTip .Point .Slot ,
433
+ updateTip .BlockNumber ,
434
+ hex .EncodeToString (updateTip .Point .Hash ),
435
+ tip .Point .Slot ,
436
+ hex .EncodeToString (tip .Point .Hash ),
437
+ )
413
438
return nil
414
439
}
415
440
@@ -541,7 +566,9 @@ func getKupoClient(c *ChainSync) (*kugo.Client, error) {
541
566
// Handle different error types
542
567
switch {
543
568
case errors .Is (err , context .DeadlineExceeded ):
544
- return nil , errors .New ("kupo health check timed out after 3 seconds" )
569
+ return nil , errors .New (
570
+ "kupo health check timed out after 3 seconds" ,
571
+ )
545
572
case strings .Contains (err .Error (), "no such host" ):
546
573
return nil , fmt .Errorf ("failed to resolve kupo host: %w" , err )
547
574
default :
@@ -551,7 +578,10 @@ func getKupoClient(c *ChainSync) (*kugo.Client, error) {
551
578
defer resp .Body .Close ()
552
579
553
580
if resp .StatusCode != http .StatusOK {
554
- return nil , fmt .Errorf ("health check failed with status code: %d" , resp .StatusCode )
581
+ return nil , fmt .Errorf (
582
+ "health check failed with status code: %d" ,
583
+ resp .StatusCode ,
584
+ )
555
585
}
556
586
557
587
c .kupoClient = k
@@ -579,15 +609,21 @@ func resolveTransactionInputs(
579
609
txIndex := int (input .Index ())
580
610
581
611
// Add timeout for matches query
582
- ctx , cancel := context .WithTimeout (context .Background (), defaultKupoTimeout )
612
+ ctx , cancel := context .WithTimeout (
613
+ context .Background (),
614
+ defaultKupoTimeout ,
615
+ )
583
616
defer cancel ()
584
617
585
618
matches , err := k .Matches (ctx ,
586
619
kugo .TxOut (chainsync .NewTxID (txId , txIndex )),
587
620
)
588
621
if err != nil {
589
622
if errors .Is (err , context .DeadlineExceeded ) {
590
- return nil , fmt .Errorf ("kupo matches query timed out after %v" , defaultKupoTimeout )
623
+ return nil , fmt .Errorf (
624
+ "kupo matches query timed out after %v" ,
625
+ defaultKupoTimeout ,
626
+ )
591
627
}
592
628
return nil , fmt .Errorf (
593
629
"error fetching matches for input TxId: %s, Index: %d. Error: %w" ,
0 commit comments