add logs for received transactions

feature/log_tx
“GheisMohammadi” 11 months ago
parent 8717ccf61d
commit 6a4f25fc89
No known key found for this signature in database
GPG Key ID: 15073AED3829FE90
  1. 8
      node/node.go
  2. 14
      node/node_handler.go

@ -221,12 +221,12 @@ func (node *Node) tryBroadcast(tx *types.Transaction) {
msg := proto_node.ConstructTransactionListMessageAccount(types.Transactions{tx})
shardGroupID := nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(tx.ShardID()))
utils.Logger().Info().Str("shardGroupID", string(shardGroupID)).Msg("tryBroadcast")
utils.Logger().Info().Str("tx_hash", tx.Hash().Hex()).Str("shardGroupID", string(shardGroupID)).Msg("tryBroadcast")
for attempt := 0; attempt < NumTryBroadCast; attempt++ {
err := node.host.SendMessageToGroups([]nodeconfig.GroupID{shardGroupID}, p2p.ConstructMessage(msg))
if err != nil {
utils.Logger().Error().Int("attempt", attempt).Msg("Error when trying to broadcast tx")
utils.Logger().Error().Str("tx_hash", tx.Hash().Hex()).Int("attempt", attempt).Msg("Error when trying to broadcast tx")
} else {
break
}
@ -239,12 +239,12 @@ func (node *Node) tryBroadcastStaking(stakingTx *staking.StakingTransaction) {
shardGroupID := nodeconfig.NewGroupIDByShardID(
nodeconfig.ShardID(shard.BeaconChainShardID),
) // broadcast to beacon chain
utils.Logger().Info().Str("shardGroupID", string(shardGroupID)).Msg("tryBroadcastStaking")
utils.Logger().Info().Str("tx_hash", stakingTx.Hash().Hex()).Str("shardGroupID", string(shardGroupID)).Msg("tryBroadcastStaking")
for attempt := 0; attempt < NumTryBroadCast; attempt++ {
if err := node.host.SendMessageToGroups([]nodeconfig.GroupID{shardGroupID},
p2p.ConstructMessage(msg)); err != nil {
utils.Logger().Error().Int("attempt", attempt).Msg("Error when trying to broadcast staking tx")
utils.Logger().Error().Str("tx_hash", stakingTx.Hash().Hex()).Int("attempt", attempt).Msg("Error when trying to broadcast staking tx")
} else {
break
}

@ -115,6 +115,13 @@ func (node *Node) transactionMessageHandler(msgPayload []byte) {
Msg("Failed to deserialize transaction list")
return
}
// log the transactions
for _, tx := range txs {
utils.Logger().Info().
Str("tx_hash", tx.Hash().Hex()).
Msg("Received a new transaction, adding to pending transactions")
}
// add txs to pending list
addPendingTransactions(node.registry, txs)
}
}
@ -132,6 +139,13 @@ func (node *Node) stakingMessageHandler(msgPayload []byte) {
Msg("Failed to deserialize staking transaction list")
return
}
// log the transactions
for _, tx := range txs {
utils.Logger().Info().
Str("tx_hash", tx.Hash().Hex()).
Msg("Received a new staking transaction, adding to pending staking transactions")
}
// add txs to pending list
node.addPendingStakingTransactions(txs)
}
}

Loading…
Cancel
Save