Skip to content

Commit

Permalink
fix: reset epoch timestamp when the reserve is reset (#4816)
Browse files Browse the repository at this point in the history
  • Loading branch information
istae authored Sep 11, 2024
1 parent ab76c0b commit 38d8d2e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/storer/internal/reserve/reserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,14 @@ func (r *Reserve) Reset(ctx context.Context) error {

size := r.Size()

err := r.st.Run(ctx, func(s transaction.Store) error { return s.IndexStore().Delete(&EpochItem{}) })
if err != nil {
return err
}

bRitems := make([]*BatchRadiusItem, 0, size)

err := r.st.IndexStore().Iterate(storage.Query{
err = r.st.IndexStore().Iterate(storage.Query{
Factory: func() storage.Item { return &BatchRadiusItem{} },
}, func(res storage.Result) (bool, error) {
bRitems = append(bRitems, res.Entry.(*BatchRadiusItem))
Expand Down
4 changes: 4 additions & 0 deletions pkg/storer/internal/reserve/reserve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,8 @@ func TestReset(t *testing.T) {
}
assert.Equal(t, c, total)

checkStore(t, ts.IndexStore(), &reserve.EpochItem{}, false)

err = r.Reset(context.Background())
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -851,6 +853,8 @@ func TestReset(t *testing.T) {
}
assert.Equal(t, c, 0)

checkStore(t, ts.IndexStore(), &reserve.EpochItem{}, true)

for _, c := range chs {
h, err := c.Stamp().Hash()
if err != nil {
Expand Down

0 comments on commit 38d8d2e

Please sign in to comment.