-
Notifications
You must be signed in to change notification settings - Fork 17
/
cmd-x-verify-index-all.go
52 lines (48 loc) · 1.22 KB
/
cmd-x-verify-index-all.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"context"
"time"
"github.com/urfave/cli/v2"
"k8s.io/klog/v2"
)
func newCmd_VerifyIndex_all() *cli.Command {
return &cli.Command{
Name: "all",
Description: "Verify all indexes.",
ArgsUsage: "<car-path> <index-cid-to-offset> <index-slot-to-cid> <index-sig-to-cid> <index-sig-exists>",
Before: func(c *cli.Context) error {
return nil
},
Flags: []cli.Flag{},
Action: func(c *cli.Context) error {
carPath := c.Args().Get(0)
indexFilePathCid2Offset := c.Args().Get(1)
indexFilePathSlot2Cid := c.Args().Get(2)
indexFilePathSig2Cid := c.Args().Get(3)
indexFilePathSigExists := c.Args().Get(4)
{
startedAt := time.Now()
defer func() {
klog.Infof("Finished in %s", time.Since(startedAt))
}()
klog.Infof("Verifying Slot-to-CID index for %s", carPath)
err := verifyAllIndexes(
context.TODO(),
carPath,
&IndexPaths{
CidToOffsetAndSize: indexFilePathCid2Offset,
SlotToCid: indexFilePathSlot2Cid,
SignatureToCid: indexFilePathSig2Cid,
SignatureExists: indexFilePathSigExists,
},
0,
)
if err != nil {
return err
}
klog.Info("Index verified successfully")
}
return nil
},
}
}