@@ -10,46 +10,27 @@ import (
10
10
// The new tail must be present in the store.
11
11
// WARNING: Only use this function if you know what you are doing.
12
12
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 {
20
14
return err
21
15
}
22
16
23
- err = batch .Commit (ctx )
24
- if err != nil {
25
- return err
26
- }
27
17
return nil
28
18
}
29
19
30
20
// ResetHead resets the head of the store to be at the given height.
31
21
// The new head must be present in the store.
32
22
// WARNING: Only use this function if you know what you are doing.
33
23
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
-
39
24
newHead , err := store .getByHeight (ctx , height )
40
25
if err != nil {
41
26
return err
42
27
}
43
28
44
- if err := writeHeaderHashTo (ctx , batch , newHead , headKey ); err != nil {
29
+ if err := writeHeaderHashTo (ctx , store . ds , newHead , headKey ); err != nil {
45
30
return err
46
31
}
47
- store .contiguousHead .Store (& newHead )
48
32
49
- err = batch .Commit (ctx )
50
- if err != nil {
51
- return err
52
- }
33
+ store .contiguousHead .Store (& newHead )
53
34
return nil
54
35
}
55
36
0 commit comments