forked from rpcpool/yellowstone-faithful
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
76 lines (64 loc) · 1.63 KB
/
main.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
import (
"context"
"fmt"
"os"
"os/signal"
"sort"
"syscall"
"github.com/ipfs/go-cid"
"github.com/urfave/cli/v2"
"k8s.io/klog/v2"
)
var gitCommitSHA = ""
func main() {
defer klog.Flush()
// set up a context that is canceled when a command is interrupted
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// set up a signal handler to cancel the context
go func() {
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, syscall.SIGTERM, syscall.SIGINT)
select {
case <-interrupt:
fmt.Println()
klog.Info("received interrupt signal")
cancel()
case <-ctx.Done():
}
// Allow any further SIGTERM or SIGINT to kill process
signal.Stop(interrupt)
}()
app := &cli.App{
Name: "faithful CLI",
Version: gitCommitSHA,
Description: "CLI to get, manage and interact with the Solana blockchain data stored in a CAR file or on Filecoin/IPFS.",
Flags: NewKlogFlagSet(),
Before: func(cctx *cli.Context) error {
return nil
},
Action: nil,
Commands: []*cli.Command{
newCmd_DumpCar(),
fetchCmd,
newCmd_Index(),
newCmd_VerifyIndex(),
newCmd_XTraverse(),
newCmd_Version(),
newCmd_rpc(),
newCmd_check_deals(),
newCmd_MergeCars(),
newCmd_SplitCar(),
},
}
sort.Sort(cli.FlagsByName(app.Flags))
sort.Sort(cli.CommandsByName(app.Commands))
if err := app.RunContext(ctx, os.Args); err != nil {
klog.Fatal(err)
}
}
// DummyCID is the "zero-length "identity" multihash with "raw" codec".
//
// This is the best-practices placeholder value to refer to a non-existent or unknown object.
var DummyCID = cid.MustParse("bafkqaaa")