add more logs for transaction and pool

feature/log_tx
“GheisMohammadi” 11 months ago
parent 6a4f25fc89
commit 9b6261f4a1
No known key found for this signature in database
GPG Key ID: 15073AED3829FE90
  1. 6
      node/node.go
  2. 3
      node/node_newblock.go

@ -286,6 +286,9 @@ func addPendingTransactions(registry *registry.Registry, newTxs types.Transactio
continue continue
} }
} }
utils.Logger().Debug().
Str("tx_hash", tx.Hash().Hex()).
Msg("[addPendingTransactions] tx is added to the txs pool array")
poolTxs = append(poolTxs, tx) poolTxs = append(poolTxs, tx)
} }
errs = append(errs, registry.GetTxPool().AddRemotes(poolTxs)...) errs = append(errs, registry.GetTxPool().AddRemotes(poolTxs)...)
@ -305,6 +308,9 @@ func (node *Node) addPendingStakingTransactions(newStakingTxs staking.StakingTra
if node.Blockchain().Config().IsPreStaking(node.Blockchain().CurrentHeader().Epoch()) { if node.Blockchain().Config().IsPreStaking(node.Blockchain().CurrentHeader().Epoch()) {
poolTxs := types.PoolTransactions{} poolTxs := types.PoolTransactions{}
for _, tx := range newStakingTxs { for _, tx := range newStakingTxs {
utils.Logger().Debug().
Str("tx_hash", tx.Hash().Hex()).
Msg("[addPendingStakingTransactions] tx is added to the txs pool array")
poolTxs = append(poolTxs, tx) poolTxs = append(poolTxs, tx)
} }
errs := node.TxPool.AddRemotes(poolTxs) errs := node.TxPool.AddRemotes(poolTxs)

@ -175,14 +175,17 @@ func (node *Node) ProposeNewBlock(commitSigs chan []byte) (*types.Block, error)
plainTxsPerAcc := types.Transactions{} plainTxsPerAcc := types.Transactions{}
for _, tx := range poolTxs { for _, tx := range poolTxs {
if plainTx, ok := tx.(*types.Transaction); ok { if plainTx, ok := tx.(*types.Transaction); ok {
utils.Logger().Info().Str("tx_hash", tx.Hash().Hex()).Msg("add transaction to proposing block")
plainTxsPerAcc = append(plainTxsPerAcc, plainTx) plainTxsPerAcc = append(plainTxsPerAcc, plainTx)
} else if stakingTx, ok := tx.(*staking.StakingTransaction); ok { } else if stakingTx, ok := tx.(*staking.StakingTransaction); ok {
// Only process staking transactions after pre-staking epoch happened. // Only process staking transactions after pre-staking epoch happened.
if node.Blockchain().Config().IsPreStaking(node.Worker.GetCurrentHeader().Epoch()) { if node.Blockchain().Config().IsPreStaking(node.Worker.GetCurrentHeader().Epoch()) {
utils.Logger().Info().Str("tx_hash", tx.Hash().Hex()).Msg("add staking transaction to proposing block")
pendingStakingTxs = append(pendingStakingTxs, stakingTx) pendingStakingTxs = append(pendingStakingTxs, stakingTx)
} }
} else { } else {
utils.Logger().Err(types.ErrUnknownPoolTxType). utils.Logger().Err(types.ErrUnknownPoolTxType).
Str("tx_hash", tx.Hash().Hex()).
Msg("Failed to parse pending transactions") Msg("Failed to parse pending transactions")
return nil, types.ErrUnknownPoolTxType return nil, types.ErrUnknownPoolTxType
} }

Loading…
Cancel
Save