github.com/core-coin/go-core/v2@v2.1.9/cmd/checkpoint-admin/main.go (about) 1 // Copyright 2019 by the Authors 2 // This file is part of go-core. 3 // 4 // go-core is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // go-core is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with go-core. If not, see <http://www.gnu.org/licenses/>. 16 17 // checkpoint-admin is a utility that can be used to query checkpoint information 18 // and register stable checkpoints into an oracle contract. 19 package main 20 21 import ( 22 "fmt" 23 "os" 24 25 "gopkg.in/urfave/cli.v1" 26 27 "github.com/core-coin/go-core/v2/common/fdlimit" 28 "github.com/core-coin/go-core/v2/internal/flags" 29 "github.com/core-coin/go-core/v2/log" 30 ) 31 32 var ( 33 // Git SHA1 commit hash of the release (set via linker flags) 34 gitTag = "" 35 gitCommit = "" 36 gitDate = "" 37 ) 38 39 var app *cli.App 40 41 func init() { 42 app = flags.NewApp(gitTag, gitCommit, gitDate, "core checkpoint helper tool") 43 app.Commands = []cli.Command{ 44 commandStatus, 45 commandDeploy, 46 commandSign, 47 commandPublish, 48 } 49 app.Flags = []cli.Flag{ 50 oracleFlag, 51 nodeURLFlag, 52 } 53 cli.CommandHelpTemplate = flags.OriginCommandHelpTemplate 54 } 55 56 // Commonly used command line flags. 57 var ( 58 indexFlag = cli.Int64Flag{ 59 Name: "index", 60 Usage: "Checkpoint index (query latest from remote node if not specified)", 61 } 62 hashFlag = cli.StringFlag{ 63 Name: "hash", 64 Usage: "Checkpoint hash (query latest from remote node if not specified)", 65 } 66 oracleFlag = cli.StringFlag{ 67 Name: "oracle", 68 Usage: "Checkpoint oracle address (query from remote node if not specified)", 69 } 70 thresholdFlag = cli.Int64Flag{ 71 Name: "threshold", 72 Usage: "Minimal number of signatures required to approve a checkpoint", 73 } 74 nodeURLFlag = cli.StringFlag{ 75 Name: "rpc", 76 Value: "http://localhost:8545", 77 Usage: "The rpc endpoint of a local or remote gocore node", 78 } 79 clefURLFlag = cli.StringFlag{ 80 Name: "clef", 81 Value: "http://localhost:8550", 82 Usage: "The rpc endpoint of clef", 83 } 84 signerFlag = cli.StringFlag{ 85 Name: "signer", 86 Usage: "Signer address for clef signing", 87 } 88 signersFlag = cli.StringFlag{ 89 Name: "signers", 90 Usage: "Comma separated accounts of trusted checkpoint signers", 91 } 92 signaturesFlag = cli.StringFlag{ 93 Name: "signatures", 94 Usage: "Comma separated checkpoint signatures to submit", 95 } 96 ) 97 98 func main() { 99 log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true)))) 100 fdlimit.Raise(2048) 101 102 if err := app.Run(os.Args); err != nil { 103 fmt.Fprintln(os.Stderr, err) 104 os.Exit(1) 105 } 106 }