@@ -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
)
@@ -580,6 +581,14 @@ func (s *Store[H]) get(ctx context.Context, hash header.Hash) ([]byte, error) {
580
581
// advanceHead moves contiguous Head forward if a newer one exists.
581
582
// It looks throw caches, pending headers and datastore
582
583
func (s * Store [H ]) advanceHead (ctx context.Context ) {
584
+ if log .Level () == zapcore .DebugLevel {
585
+ now := time .Now ()
586
+ log .Debug ("advancing head" )
587
+ defer func () {
588
+ log .Debugw ("finished advancing head" , "took(s)" , time .Since (now ))
589
+ }()
590
+ }
591
+
583
592
newHead , changed := s .nextHead (ctx )
584
593
if changed {
585
594
s .contiguousHead .Store (& newHead )
@@ -614,6 +623,15 @@ func (s *Store[H]) nextHead(ctx context.Context) (head H, changed bool) {
614
623
if err != nil {
615
624
return head , changed
616
625
}
626
+
627
+ if ! changed && log .Level () == zapcore .DebugLevel {
628
+ now := time .Now ()
629
+ log .Debugw ("advancing head" , "start_height" , head .Height ())
630
+ defer func () {
631
+ log .Debugw ("finished advancing head" , "end_height" , head .Height (), "took(s)" , time .Since (now ))
632
+ }()
633
+ }
634
+
617
635
head = h
618
636
changed = true
619
637
}
@@ -635,6 +653,15 @@ func (s *Store[H]) nextTail(ctx context.Context) (tail H, changed bool) {
635
653
if err != nil {
636
654
return tail , changed
637
655
}
656
+
657
+ if ! changed && log .Level () == zapcore .DebugLevel {
658
+ now := time .Now ()
659
+ log .Debugw ("receding tail" , "start_height" , tail .Height ())
660
+ defer func () {
661
+ log .Debugw ("finished receding tail" , "end_height" , tail .Height (), "took(s)" , time .Since (now ))
662
+ }()
663
+ }
664
+
638
665
tail = h
639
666
changed = true
640
667
}
0 commit comments