From 4624bbb988885159ba278a2053d29a122f3f6884 Mon Sep 17 00:00:00 2001 From: AnilChinchawale Date: Sat, 24 Nov 2018 16:23:43 +0530 Subject: [PATCH] updated utils.go --- cmd/utils/flags.go | 5 +++-- contracts/utils.go | 26 ++++++++++++++++++++++---- contracts/utils_test.go | 17 ++++++++++++++++- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 1a6c1210e0..dfdc170977 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -74,8 +74,10 @@ SUBCOMMANDS: func init() { cli.AppHelpTemplate = `{{.Name}} {{if .Flags}}[global options] {{end}}command{{if .Flags}} [command options]{{end}} [arguments...] + VERSION: {{.Version}} + COMMANDS: {{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}} {{end}}{{if .Flags}} @@ -1084,7 +1086,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { // TODO(fjl): force-enable this in --dev mode cfg.EnablePreimageRecording = ctx.GlobalBool(VMEnableDebugFlag.Name) } - if ctx.GlobalIsSet(StoreRewardFlag.Name) { cfg.StoreRewardFolder = filepath.Join(stack.DataDir(), "XDC", "rewards") if _, err := os.Stat(cfg.StoreRewardFolder); os.IsNotExist(err) { @@ -1314,4 +1315,4 @@ func MigrateFlags(action func(ctx *cli.Context) error) func(*cli.Context) error } return action(ctx) } -} \ No newline at end of file +} diff --git a/contracts/utils.go b/contracts/utils.go index 41ee875748..21dd0f799c 100644 --- a/contracts/utils.go +++ b/contracts/utils.go @@ -1,3 +1,18 @@ +// Copyright (c) 2018 XDCchain +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . + package contracts import ( @@ -298,7 +313,8 @@ func GetRewardForCheckpoint(chain consensus.ChainReader, blockSignerAddr common. block := chain.GetHeaderByNumber(i) addrs, err := GetSignersFromContract(blockSignerAddr, client, block.Hash()) if err != nil { - log.Crit("Fail to get signers from smartcontract.", "error", err, "blockNumber", i) + log.Error("Fail to get signers from smartcontract.", "error", err, "blockNumber", i) + return nil, err } // Filter duplicate address. if len(addrs) > 0 { @@ -395,7 +411,8 @@ func GetRewardBalancesRate(foudationWalletAddr common.Address, masterAddr common opts := new(bind.CallOpts) voters, err := validator.GetVoters(opts, masterAddr) if err != nil { - log.Crit("Fail to get voters", "error", err) + log.Error("Fail to get voters", "error", err) + return nil, err } if len(voters) > 0 { @@ -407,7 +424,8 @@ func GetRewardBalancesRate(foudationWalletAddr common.Address, masterAddr common for _, voteAddr := range voters { voterCap, err := validator.GetVoterCap(opts, masterAddr, voteAddr) if err != nil { - log.Crit("Fail to get vote capacity", "error", err) + log.Error("Fail to get vote capacity", "error", err) + return nil, err } totalCap.Add(totalCap, voterCap) @@ -538,4 +556,4 @@ func isInt(strNumber string) bool { } else { return false } -} \ No newline at end of file +} diff --git a/contracts/utils_test.go b/contracts/utils_test.go index 48b1e7e409..f51b3f1f75 100644 --- a/contracts/utils_test.go +++ b/contracts/utils_test.go @@ -1,3 +1,18 @@ +// Copyright (c) 2018 XDCchain +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . + package contracts import ( @@ -193,4 +208,4 @@ func TestDecodeValidatorsHexData(t *testing.T) { t.Errorf("Fail to get m2 result %v", b) } t.Log("b", b) -} \ No newline at end of file +}