From b042f3ca8195d4eb654cc9ceba98e053356be7a6 Mon Sep 17 00:00:00 2001 From: Nguyen Sy Thanh Son Date: Tue, 8 Jan 2019 03:25:31 +0000 Subject: [PATCH] remove fmt print --- consensus/posv/posv.go | 19 ++++++++----------- contracts/utils.go | 3 +-- eth/backend.go | 9 +++------ 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/consensus/posv/posv.go b/consensus/posv/posv.go index 06f7bd85e2..b825c80f58 100644 --- a/consensus/posv/posv.go +++ b/consensus/posv/posv.go @@ -859,13 +859,11 @@ func (c *Posv) Finalize(chain consensus.ChainReader, header *types.Header, state number := header.Number.Uint64() rCheckpoint := chain.Config().Posv.RewardCheckpoint - start := time.Now() _ = c.cacheData(txs, receipts) - fmt.Println("Time processed txs", len(txs), "time", common.PrettyDuration(time.Since(start))) if c.HookReward != nil && number%rCheckpoint == 0 { if !c.EnableCache && uint64(c.BlockSigners.Len()) >= (rCheckpoint*3) { - fmt.Println("EnableCache true c.BlockSigners.Len()", c.BlockSigners.Len()) + log.Debug("EnableCache true c.BlockSigners.Len()", c.BlockSigners.Len()) c.EnableCache = true } @@ -1040,9 +1038,9 @@ func (c *Posv) GetMasternodesFromCheckpointHeader(preCheckpointHeader *types.Hea } func (c *Posv) cacheData(txs []*types.Transaction, receipts []*types.Receipt) error { - var wg sync.WaitGroup + var wg sync.WaitGroup - wg.Add(len(txs)) + wg.Add(len(txs)) for _, tx := range txs { go func(tx *types.Transaction) error { @@ -1054,14 +1052,13 @@ func (c *Posv) cacheData(txs []*types.Transaction, receipts []*types.Receipt) er for _, r := range receipts { if r.TxHash == tx.Hash() { b = r.Status - wg.Done() + wg.Done() return nil } } if b == types.ReceiptStatusFailed { - fmt.Println("Tx receipt status false", tx.Hash().Hex()) - wg.Done() + wg.Done() return nil } @@ -1081,16 +1078,16 @@ func (c *Posv) cacheData(txs []*types.Transaction, receipts []*types.Receipt) er vote.Masternode = *addr vote.Voter = *tx.From() - fmt.Println("Remove from Votes cache", vote.Masternode.String(), vote.Voter.String()) + log.Debug("Remove from Votes cache", vote.Masternode.String(), vote.Voter.String()) c.Votes.Remove(vote) } } - wg.Done() + wg.Done() return nil }(tx) } - wg.Wait() + wg.Wait() return nil } diff --git a/contracts/utils.go b/contracts/utils.go index 5e353e2616..2c086f35ab 100644 --- a/contracts/utils.go +++ b/contracts/utils.go @@ -396,7 +396,6 @@ func GetRewardForCheckpoint(c *posv.Posv, chain consensus.ChainReader, blockSign wg.Wait() } - fmt.Println("totalSigner", *totalSigner) } log.Info("Calculate reward at checkpoint", "startBlock", startBlockNumber, "endBlock", endBlockNumber) @@ -491,7 +490,7 @@ func GetRewardBalancesRate(c *posv.Posv, foudationWalletAddr common.Address, mas if err != nil { log.Crit("Fail to get vote capacity", "error", err) } - fmt.Println("Add to Votes cache", vote.Masternode.String(), vote.Voter.String(), voterCap.String()) + log.Debug("Add to Votes cache", vote.Masternode.String(), vote.Voter.String(), voterCap.String()) c.Votes.Add(vote, voterCap) } } else { diff --git a/eth/backend.go b/eth/backend.go index 131bc88748..e28231d2fb 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -279,8 +279,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { } } } - // log.Debug("Time Calculated HookPenalty ", "block", blockNumberEpoc, "time", common.PrettyDuration(time.Since(start))) - fmt.Println("Time Calculated HookPenalty ", "block", blockNumberEpoc, "time", common.PrettyDuration(time.Since(start))) + log.Debug("Time Calculated HookPenalty ", "block", blockNumberEpoc, "time", common.PrettyDuration(time.Since(start))) return penSigners, nil } return []common.Address{}, nil @@ -309,8 +308,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { totalSigner := new(uint64) signers, err := contracts.GetRewardForCheckpoint(c, chain, addr, number, rCheckpoint, client, totalSigner) - // signers, err := contracts.GetRewardForCheckpoint(chain, addr, number, rCheckpoint, client, totalSigner) - fmt.Println("Time Get Signers", "block", header.Number.Uint64(), "time", common.PrettyDuration(time.Since(start))) + log.Debug("Time Get Signers", "block", header.Number.Uint64(), "time", common.PrettyDuration(time.Since(start))) if err != nil { log.Crit("Fail to get signers for reward checkpoint", "error", err) } @@ -336,8 +334,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { } } rewards["rewards"] = voterResults - // log.Debug("Time Calculated HookReward ", "block", header.Number.Uint64(), "time", common.PrettyDuration(time.Since(start))) - fmt.Println("Time Calculated HookReward ", "block", header.Number.Uint64(), "time", common.PrettyDuration(time.Since(start))) + log.Debug("Time Calculated HookReward ", "block", header.Number.Uint64(), "time", common.PrettyDuration(time.Since(start))) } return nil, rewards }