From ffb18c9dd66b61d45ae4cf6c1cf52fd1d86ea8a8 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Tue, 18 Jun 2024 14:11:18 +0200 Subject: [PATCH] feat(store): add tail header --- store/store.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/store/store.go b/store/store.go index 657a22c7..bd4cb3af 100644 --- a/store/store.go +++ b/store/store.go @@ -51,6 +51,8 @@ type Store[H header.Header[H]] struct { writesDn chan struct{} // writeHead maintains the current write head writeHead atomic.Pointer[H] + // tailHeader maintains the current tail header. + tailHeader atomic.Pointer[H] // pending keeps headers pending to be written in one batch pending *batch[H] @@ -121,6 +123,8 @@ func (s *Store[H]) Init(ctx context.Context, initial H) error { return err } + s.tailHeader.Store(&initial) + log.Infow("initialized head", "height", initial.Height(), "hash", initial.Hash()) s.heightSub.Pub(initial) return nil