gitee.com/liu-zhao234568/cntest@v1.0.0/cmd/checkpoint-admin/main.go (about)

     1  // Copyright 2019 The go-ethereum Authors
     2  // This file is part of go-ethereum.
     3  //
     4  // go-ethereum 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-ethereum 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-ethereum. 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  	"gitee.com/liu-zhao234568/cntest/common/fdlimit"
    26  	"gitee.com/liu-zhao234568/cntest/internal/flags"
    27  	"gitee.com/liu-zhao234568/cntest/log"
    28  	"gopkg.in/urfave/cli.v1"
    29  )
    30  
    31  var (
    32  	// Git SHA1 commit hash of the release (set via linker flags)
    33  	gitCommit = ""
    34  	gitDate   = ""
    35  )
    36  
    37  var app *cli.App
    38  
    39  func init() {
    40  	app = flags.NewApp(gitCommit, gitDate, "ethereum checkpoint helper tool")
    41  	app.Commands = []cli.Command{
    42  		commandStatus,
    43  		commandDeploy,
    44  		commandSign,
    45  		commandPublish,
    46  	}
    47  	app.Flags = []cli.Flag{
    48  		oracleFlag,
    49  		nodeURLFlag,
    50  	}
    51  	cli.CommandHelpTemplate = flags.OriginCommandHelpTemplate
    52  }
    53  
    54  // Commonly used command line flags.
    55  var (
    56  	indexFlag = cli.Int64Flag{
    57  		Name:  "index",
    58  		Usage: "Checkpoint index (query latest from remote node if not specified)",
    59  	}
    60  	hashFlag = cli.StringFlag{
    61  		Name:  "hash",
    62  		Usage: "Checkpoint hash (query latest from remote node if not specified)",
    63  	}
    64  	oracleFlag = cli.StringFlag{
    65  		Name:  "oracle",
    66  		Usage: "Checkpoint oracle address (query from remote node if not specified)",
    67  	}
    68  	thresholdFlag = cli.Int64Flag{
    69  		Name:  "threshold",
    70  		Usage: "Minimal number of signatures required to approve a checkpoint",
    71  	}
    72  	nodeURLFlag = cli.StringFlag{
    73  		Name:  "rpc",
    74  		Value: "http://localhost:8545",
    75  		Usage: "The rpc endpoint of a local or remote geth node",
    76  	}
    77  	clefURLFlag = cli.StringFlag{
    78  		Name:  "clef",
    79  		Value: "http://localhost:8550",
    80  		Usage: "The rpc endpoint of clef",
    81  	}
    82  	signerFlag = cli.StringFlag{
    83  		Name:  "signer",
    84  		Usage: "Signer address for clef signing",
    85  	}
    86  	signersFlag = cli.StringFlag{
    87  		Name:  "signers",
    88  		Usage: "Comma separated accounts of trusted checkpoint signers",
    89  	}
    90  	signaturesFlag = cli.StringFlag{
    91  		Name:  "signatures",
    92  		Usage: "Comma separated checkpoint signatures to submit",
    93  	}
    94  )
    95  
    96  func main() {
    97  	log.Root().SetHandler(log.LvlFilterHandler(log.LvlInfo, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
    98  	fdlimit.Raise(2048)
    99  
   100  	if err := app.Run(os.Args); err != nil {
   101  		fmt.Fprintln(os.Stderr, err)
   102  		os.Exit(1)
   103  	}
   104  }