@@ -12,6 +12,7 @@ import (
12
12
"github.com/ipfs/go-datastore"
13
13
"github.com/ipfs/go-datastore/namespace"
14
14
logging "github.com/ipfs/go-log/v2"
15
+ "go.uber.org/zap/zapcore"
15
16
16
17
"github.com/celestiaorg/go-header"
17
18
)
@@ -583,6 +584,14 @@ func (s *Store[H]) get(ctx context.Context, hash header.Hash) ([]byte, error) {
583
584
// advanceHead moves contiguous Head forward if a newer one exists.
584
585
// It looks throw caches, pending headers and datastore
585
586
func (s * Store [H ]) advanceHead (ctx context.Context ) {
587
+ if log .Level () == zapcore .DebugLevel {
588
+ now := time .Now ()
589
+ log .Debug ("advancing head" )
590
+ defer func () {
591
+ log .Debugw ("finished advancing head" , "took(s)" , time .Since (now ))
592
+ }()
593
+ }
594
+
586
595
newHead , changed := s .nextHead (ctx )
587
596
if changed {
588
597
s .contiguousHead .Store (& newHead )
@@ -617,6 +626,15 @@ func (s *Store[H]) nextHead(ctx context.Context) (head H, changed bool) {
617
626
if err != nil {
618
627
return head , changed
619
628
}
629
+
630
+ if ! changed && log .Level () == zapcore .DebugLevel {
631
+ now := time .Now ()
632
+ log .Debugw ("advancing head" , "start_height" , head .Height ())
633
+ defer func () {
634
+ log .Debugw ("finished advancing head" , "end_height" , head .Height (), "took(s)" , time .Since (now ))
635
+ }()
636
+ }
637
+
620
638
head = h
621
639
changed = true
622
640
}
@@ -638,6 +656,15 @@ func (s *Store[H]) nextTail(ctx context.Context) (tail H, changed bool) {
638
656
if err != nil {
639
657
return tail , changed
640
658
}
659
+
660
+ if ! changed && log .Level () == zapcore .DebugLevel {
661
+ now := time .Now ()
662
+ log .Debugw ("receding tail" , "start_height" , tail .Height ())
663
+ defer func () {
664
+ log .Debugw ("finished receding tail" , "end_height" , tail .Height (), "took(s)" , time .Since (now ))
665
+ }()
666
+ }
667
+
641
668
tail = h
642
669
changed = true
643
670
}
0 commit comments