updated utils.go

This commit is contained in:
AnilChinchawale 2018-11-24 16:23:43 +05:30
parent 4e0099cd7e
commit 4624bbb988
3 changed files with 41 additions and 7 deletions

View file

@ -74,8 +74,10 @@ SUBCOMMANDS:
func init() { func init() {
cli.AppHelpTemplate = `{{.Name}} {{if .Flags}}[global options] {{end}}command{{if .Flags}} [command options]{{end}} [arguments...] cli.AppHelpTemplate = `{{.Name}} {{if .Flags}}[global options] {{end}}command{{if .Flags}} [command options]{{end}} [arguments...]
VERSION: VERSION:
{{.Version}} {{.Version}}
COMMANDS: COMMANDS:
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}} {{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
{{end}}{{if .Flags}} {{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 // TODO(fjl): force-enable this in --dev mode
cfg.EnablePreimageRecording = ctx.GlobalBool(VMEnableDebugFlag.Name) cfg.EnablePreimageRecording = ctx.GlobalBool(VMEnableDebugFlag.Name)
} }
if ctx.GlobalIsSet(StoreRewardFlag.Name) { if ctx.GlobalIsSet(StoreRewardFlag.Name) {
cfg.StoreRewardFolder = filepath.Join(stack.DataDir(), "XDC", "rewards") cfg.StoreRewardFolder = filepath.Join(stack.DataDir(), "XDC", "rewards")
if _, err := os.Stat(cfg.StoreRewardFolder); os.IsNotExist(err) { if _, err := os.Stat(cfg.StoreRewardFolder); os.IsNotExist(err) {

View file

@ -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 <http://www.gnu.org/licenses/>.
package contracts package contracts
import ( import (
@ -298,7 +313,8 @@ func GetRewardForCheckpoint(chain consensus.ChainReader, blockSignerAddr common.
block := chain.GetHeaderByNumber(i) block := chain.GetHeaderByNumber(i)
addrs, err := GetSignersFromContract(blockSignerAddr, client, block.Hash()) addrs, err := GetSignersFromContract(blockSignerAddr, client, block.Hash())
if err != nil { 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. // Filter duplicate address.
if len(addrs) > 0 { if len(addrs) > 0 {
@ -395,7 +411,8 @@ func GetRewardBalancesRate(foudationWalletAddr common.Address, masterAddr common
opts := new(bind.CallOpts) opts := new(bind.CallOpts)
voters, err := validator.GetVoters(opts, masterAddr) voters, err := validator.GetVoters(opts, masterAddr)
if err != nil { 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 { if len(voters) > 0 {
@ -407,7 +424,8 @@ func GetRewardBalancesRate(foudationWalletAddr common.Address, masterAddr common
for _, voteAddr := range voters { for _, voteAddr := range voters {
voterCap, err := validator.GetVoterCap(opts, masterAddr, voteAddr) voterCap, err := validator.GetVoterCap(opts, masterAddr, voteAddr)
if err != nil { 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) totalCap.Add(totalCap, voterCap)

View file

@ -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 <http://www.gnu.org/licenses/>.
package contracts package contracts
import ( import (