removed zero logger for the flow added in this pr

pull/1319/head
Dennis Won 5 years ago
parent df7bb99d46
commit af858d93e6
  1. 10
      node/node.go
  2. 48
      node/worker/worker.go

@ -271,11 +271,11 @@ func (node *Node) getTransactionsForNewBlock(coinbase common.Address) types.Tran
node.pendingTransactions = unselected node.pendingTransactions = unselected
node.reducePendingTransactions() node.reducePendingTransactions()
utils.Logger().Info(). utils.GetLogInstance().Info(
Int("remainPending", len(node.pendingTransactions)). "msg", "Selecting Transactions",
Int("selected", len(selected)). "newBlockNum", newBlockNum,
Int("invalidDiscarded", len(invalid)). "remainPending", len(node.pendingTransactions),
Msg("Selecting Transactions") "invalidDiscarded", len(invalid))
node.pendingTxMutex.Unlock() node.pendingTxMutex.Unlock()
return selected return selected

@ -59,25 +59,25 @@ func (w *Worker) throttleTxs(selected types.Transactions, recentTxsStats types.R
var sender common.Address var sender common.Address
msg, err := tx.AsMessage(s) msg, err := tx.AsMessage(s)
if err != nil { if err != nil {
utils.Logger().Error().Msg("Error when parsing tx into message") utils.GetLogInstance().Error("Error when parsing tx into message", "msg", err)
} else { } else {
sender = msg.From() sender = msg.From()
} }
// already selected max num txs // already selected max num txs
if len(selected) > (*txsThrottleConfig).MaxTxsPerBlockLimit { if len(selected) > (*txsThrottleConfig).MaxTxsPerBlockLimit {
utils.Logger().Debug(). utils.GetLogInstance().Info(
Int("MaxTxsPerBlockLimit", (*txsThrottleConfig).MaxTxsPerBlockLimit). "msg", "Throttling tx with max txs per block limit",
Msg("Throttling tx with max txs per block limit") "MaxTxsPerBlockLimit", txsThrottleConfig.MaxTxsPerBlockLimit)
return sender, shardingconfig.TxUnselect return sender, shardingconfig.TxUnselect
} }
// throttle a single sender sending too many transactions in one block // throttle a single sender sending too many transactions in one block
if ((*txsThrottleConfig).MaxTxAmountLimit).Cmp(tx.Value()) < 0 { if (txsThrottleConfig.MaxTxAmountLimit).Cmp(tx.Value()) < 0 {
utils.Logger().Debug(). utils.GetLogInstance().Info(
Uint64("MaxTxAmountLimit", (*txsThrottleConfig).MaxTxAmountLimit.Uint64()). "msg", "Throttling tx with max amount limit",
Uint64("Tx amount", tx.Value().Uint64()). "MaxTxAmountLimit", txsThrottleConfig.MaxTxAmountLimit.Uint64(),
Msg("Throttling tx with max amount limit") "Tx amount", tx.Value().Uint64())
return sender, shardingconfig.TxInvalid return sender, shardingconfig.TxInvalid
} }
@ -86,10 +86,10 @@ func (w *Worker) throttleTxs(selected types.Transactions, recentTxsStats types.R
for _, blockTxsCounts := range recentTxsStats { for _, blockTxsCounts := range recentTxsStats {
numTxsPastHour += blockTxsCounts[sender] numTxsPastHour += blockTxsCounts[sender]
} }
if numTxsPastHour >= (*txsThrottleConfig).MaxNumRecentTxsPerAccountLimit { if numTxsPastHour >= txsThrottleConfig.MaxNumRecentTxsPerAccountLimit {
utils.Logger().Debug(). utils.GetLogInstance().Info(
Uint64("MaxNumRecentTxsPerAccountLimit", (*txsThrottleConfig).MaxNumRecentTxsPerAccountLimit). "msg", "Throttling tx with max txs per account in a single block limit",
Msg("Throttling tx with max txs per account in a single block limit") "MaxNumRecentTxsPerAccountLimit", txsThrottleConfig.MaxNumRecentTxsPerAccountLimit)
return sender, shardingconfig.TxUnselect return sender, shardingconfig.TxUnselect
} }
@ -114,17 +114,9 @@ func (w *Worker) SelectTransactionsForNewBlock(newBlockNum uint64, txs types.Tra
switch flag { switch flag {
case shardingconfig.TxUnselect: case shardingconfig.TxUnselect:
unselected = append(unselected, tx) unselected = append(unselected, tx)
utils.Logger().Info().
Str("Transaction Id", tx.Hash().Hex()).
Str("txThrottleFlag", flag.String()).
Msg("Transaction Throttle flag")
case shardingconfig.TxInvalid: case shardingconfig.TxInvalid:
invalid = append(invalid, tx) invalid = append(invalid, tx)
utils.Logger().Info().
Str("txThrottleFlag", flag.String()).
Str("Transaction Id", tx.Hash().Hex()).
Msg("Transaction Throttle flag")
case shardingconfig.TxSelect: case shardingconfig.TxSelect:
snap := w.current.state.Snapshot() snap := w.current.state.Snapshot()
@ -132,16 +124,20 @@ func (w *Worker) SelectTransactionsForNewBlock(newBlockNum uint64, txs types.Tra
if err != nil { if err != nil {
w.current.state.RevertToSnapshot(snap) w.current.state.RevertToSnapshot(snap)
invalid = append(invalid, tx) invalid = append(invalid, tx)
utils.Logger().Error().
Err(err).
Str("Transaction Id", tx.Hash().Hex()).
Str("txThrottleFlag", flag.String()).
Msg("Transaction Throttle flag")
} else { } else {
selected = append(selected, tx) selected = append(selected, tx)
recentTxsStats[newBlockNum][sender]++ recentTxsStats[newBlockNum][sender]++
} }
} }
// log invalid or unselected txs
if flag == shardingconfig.TxUnselect || flag == shardingconfig.TxInvalid {
utils.GetLogInstance().Info(
"msg", "Transaction Throttle flag",
"Transaction Id", tx.Hash().Hex(),
"txThrottleFlag", flag.String())
}
} }
return selected, unselected, invalid return selected, unselected, invalid
} }

Loading…
Cancel
Save