Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
46f8fad
fix(store): track store's contiguous head
cristaloleg Jan 8, 2025
cbcb738
more fixes
cristaloleg Jan 8, 2025
4bc4aa0
fix test
cristaloleg Jan 8, 2025
9e19840
fix sync test
cristaloleg Jan 8, 2025
cc8894c
fix sync test
cristaloleg Jan 8, 2025
73b65f2
test heightSub
cristaloleg Jan 9, 2025
b74e825
simplify test
cristaloleg Jan 9, 2025
2a317ad
wip
cristaloleg Jan 10, 2025
1903695
cleanup
cristaloleg Jan 10, 2025
268afc3
simplify heightSub
cristaloleg Jan 10, 2025
674e461
fix tests
cristaloleg Jan 13, 2025
a68fd8a
fixes
cristaloleg Jan 13, 2025
7c3cc9b
fix ctx
cristaloleg Jan 13, 2025
5d89381
review suggestions
cristaloleg Jan 14, 2025
b267831
rebase
cristaloleg Jan 14, 2025
beda8d1
tests
cristaloleg Jan 15, 2025
311561b
more tests
cristaloleg Jan 15, 2025
22a4b2f
review suggestions
cristaloleg Jan 22, 2025
26e6621
small refactoring
cristaloleg Jan 22, 2025
06e73c1
add heightSub.Init
cristaloleg Jan 23, 2025
b506084
do 1 more fetch before subscribe
cristaloleg Jan 23, 2025
7b5b282
review suggestions
cristaloleg Jan 24, 2025
ac9eb8c
do advance at start
cristaloleg Jan 24, 2025
7a53bc7
load key on start
cristaloleg Jan 27, 2025
3089d68
fix finding
cristaloleg Jan 27, 2025
75b0141
review suggestions
cristaloleg Jan 27, 2025
8194f52
rename to a better name
cristaloleg Jan 27, 2025
1375bd3
even better names
cristaloleg Jan 27, 2025
e9fbde6
sky is the limit
cristaloleg Jan 27, 2025
07babe7
hehe
cristaloleg Jan 27, 2025
459baad
drop param
cristaloleg Jan 27, 2025
9f1c92b
review suggestions
cristaloleg Jan 30, 2025
d554c55
fix
cristaloleg Jan 31, 2025
034e618
revert
cristaloleg Jan 31, 2025
aa97c39
more review suggestions
cristaloleg Feb 4, 2025
f2d860c
simplify
cristaloleg Feb 4, 2025
5518222
simplify again
cristaloleg Feb 4, 2025
aef55c4
simplify
cristaloleg Feb 4, 2025
ac051e4
linter
cristaloleg Feb 4, 2025
35856eb
think different
cristaloleg Feb 4, 2025
73b5c89
more suggestions
cristaloleg Feb 5, 2025
84a7090
upd cmnt
cristaloleg Feb 5, 2025
921de51
revert head method
cristaloleg Feb 13, 2025
dc6d5bf
revert but a bit
cristaloleg Feb 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,24 @@ func (s *Store[H]) Height() uint64 {
return s.heightSub.Height()
}

func (s *Store[H]) Head(_ context.Context, _ ...header.HeadOption[H]) (H, error) {
if head := s.contiguousHead.Load(); head != nil {
return *head, nil
func (s *Store[H]) Head(ctx context.Context, _ ...header.HeadOption[H]) (H, error) {
head, err := s.GetByHeight(ctx, s.heightSub.Height())
if err == nil {
return head, nil
}

var zero H
return zero, header.ErrNoHead
head, err = s.readHead(ctx)
switch {
default:
return zero, err
case errors.Is(err, datastore.ErrNotFound), errors.Is(err, header.ErrNotFound):
return zero, header.ErrNoHead
case err == nil:
s.heightSub.SetHeight(head.Height())
log.Infow("loaded head", "height", head.Height(), "hash", head.Hash())
return head, nil
}
}

func (s *Store[H]) Get(ctx context.Context, hash header.Hash) (H, error) {
Expand Down