github.com/Deepchain-foundation/go-ethereum@v1.9.7/cmd/checkpoint-admin/status.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  package main
    18  
    19  import (
    20  	"fmt"
    21  
    22  	"github.com/ethereum/go-ethereum/cmd/utils"
    23  	"github.com/ethereum/go-ethereum/common"
    24  	"gopkg.in/urfave/cli.v1"
    25  )
    26  
    27  var commandStatus = cli.Command{
    28  	Name:  "status",
    29  	Usage: "Fetches the signers and checkpoint status of the oracle contract",
    30  	Flags: []cli.Flag{
    31  		nodeURLFlag,
    32  	},
    33  	Action: utils.MigrateFlags(status),
    34  }
    35  
    36  // status fetches the admin list of specified registrar contract.
    37  func status(ctx *cli.Context) error {
    38  	// Create a wrapper around the checkpoint oracle contract
    39  	addr, oracle := newContract(newRPCClient(ctx.GlobalString(nodeURLFlag.Name)))
    40  	fmt.Printf("Oracle => %s\n", addr.Hex())
    41  	fmt.Println()
    42  
    43  	// Retrieve the list of authorized signers (admins)
    44  	admins, err := oracle.Contract().GetAllAdmin(nil)
    45  	if err != nil {
    46  		return err
    47  	}
    48  	for i, admin := range admins {
    49  		fmt.Printf("Admin %d => %s\n", i+1, admin.Hex())
    50  	}
    51  	fmt.Println()
    52  
    53  	// Retrieve the latest checkpoint
    54  	index, checkpoint, height, err := oracle.Contract().GetLatestCheckpoint(nil)
    55  	if err != nil {
    56  		return err
    57  	}
    58  	fmt.Printf("Checkpoint (published at #%d) %d => %s\n", height, index, common.Hash(checkpoint).Hex())
    59  
    60  	return nil
    61  }