-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathcmd-x-verify-index-all.go
More file actions
78 lines (74 loc) · 2.06 KB
/
cmd-x-verify-index-all.go
File metadata and controls
78 lines (74 loc) · 2.06 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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.",
Before: func(c *cli.Context) error {
return nil
},
Flags: []cli.Flag{
&cli.StringSliceFlag{
Name: "car",
Usage: "Path to a CAR file containing a single Solana epoch, or multiple split CAR files (in order) containing a single Solana epoch",
},
&cli.StringFlag{
Name: "index-cid-to-offset-and-size",
Usage: "Path to the CID-to-offset index file",
},
&cli.StringFlag{
Name: "index-slot-to-cid",
Usage: "Path to the slot-to-CID index file",
},
&cli.StringFlag{
Name: "index-sig-to-cid",
Usage: "Path to the signature-to-CID index file",
},
&cli.StringFlag{
Name: "index-sig-exists",
Usage: "Path to the signature-exists index file",
},
&cli.StringFlag{
Name: "index-slot-to-blocktime",
Usage: "Path to the slot-to-blocktime index file",
},
},
Action: func(c *cli.Context) error {
carPaths := c.StringSlice("car")
indexFilePathCid2OffsetAndSize := c.String("index-cid-to-offset-and-size")
indexFilePathSlot2Cid := c.String("index-slot-to-cid")
indexFilePathSig2Cid := c.String("index-sig-to-cid")
indexFilePathSigExists := c.String("index-sig-exists")
indexFilePathSlot2Blocktime := c.String("index-slot-to-blocktime")
{
startedAt := time.Now()
defer func() {
klog.Infof("Finished in %s", time.Since(startedAt))
}()
klog.Infof("Verifying indexes for %v", carPaths)
err := verifyAllIndexes(
context.TODO(),
carPaths,
&IndexPaths{
CidToOffsetAndSize: indexFilePathCid2OffsetAndSize,
SlotToCid: indexFilePathSlot2Cid,
SignatureToCid: indexFilePathSig2Cid,
SignatureExists: indexFilePathSigExists,
SlotToBlocktime: indexFilePathSlot2Blocktime,
},
0,
)
if err != nil {
return err
}
klog.Info("Index verified successfully")
}
return nil
},
}
}