Skip to content

Commit 841b13e

Browse files
committed
fixes
1 parent 0c9c651 commit 841b13e

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

store/store.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -584,14 +584,6 @@ func (s *Store[H]) get(ctx context.Context, hash header.Hash) ([]byte, error) {
584584
// advanceHead moves contiguous Head forward if a newer one exists.
585585
// It looks throw caches, pending headers and datastore
586586
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-
595587
newHead, changed := s.nextHead(ctx)
596588
if changed {
597589
s.contiguousHead.Store(&newHead)

store/store_delete.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ func (s *Store[H]) deleteSequential(ctx context.Context, from, to uint64) (err e
130130
}
131131
}
132132

133+
if err := batch.Commit(ctx); err != nil {
134+
return fmt.Errorf("committing batch: %w", err)
135+
}
136+
133137
return nil
134138
}
135139

store/store_recover.go

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,27 @@ import (
1010
// The new tail must be present in the store.
1111
// WARNING: Only use this function if you know what you are doing.
1212
func ResetTail[H header.Header[H]](ctx context.Context, store *Store[H], height uint64) error {
13-
batch, err := store.ds.Batch(ctx)
14-
if err != nil {
15-
return err
16-
}
17-
18-
err = store.setTail(ctx, batch, height)
19-
if err != nil {
13+
if err := store.setTail(ctx, store.ds, height); err != nil {
2014
return err
2115
}
2216

23-
err = batch.Commit(ctx)
24-
if err != nil {
25-
return err
26-
}
2717
return nil
2818
}
2919

3020
// ResetHead resets the head of the store to be at the given height.
3121
// The new head must be present in the store.
3222
// WARNING: Only use this function if you know what you are doing.
3323
func ResetHead[H header.Header[H]](ctx context.Context, store *Store[H], height uint64) error {
34-
batch, err := store.ds.Batch(ctx)
35-
if err != nil {
36-
return err
37-
}
38-
3924
newHead, err := store.getByHeight(ctx, height)
4025
if err != nil {
4126
return err
4227
}
4328

44-
if err := writeHeaderHashTo(ctx, batch, newHead, headKey); err != nil {
29+
if err := writeHeaderHashTo(ctx, store.ds, newHead, headKey); err != nil {
4530
return err
4631
}
47-
store.contiguousHead.Store(&newHead)
4832

49-
err = batch.Commit(ctx)
50-
if err != nil {
51-
return err
52-
}
33+
store.contiguousHead.Store(&newHead)
5334
return nil
5435
}
5536

0 commit comments

Comments
 (0)