Skip to content

Commit

Permalink
add worker logs
Browse files Browse the repository at this point in the history
  • Loading branch information
linhnt3400 committed Nov 25, 2024
1 parent b78855b commit 292f578
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/server/tradelogs/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (s *Server) getTradeLogs(c *gin.Context) {
responseErr(c, http.StatusBadRequest, errors.New("max time range"))
return
}
s.l.Infow("get trade log query", "query", query)
data, err := s.s.Get(query)
if err != nil {
responseErr(c, http.StatusBadRequest, err)
Expand Down
2 changes: 2 additions & 0 deletions internal/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (w *Worker) Run(ctx context.Context) error {
}
func (w *Worker) processMessages(m []evmlistenerclient.Message) error {
for _, message := range m {
w.l.Infow("about to process new message", "msg", message)
var (
insertOrders []storage.TradeLog
deleteBlocks []uint64
Expand All @@ -91,6 +92,7 @@ func (w *Worker) processMessages(m []evmlistenerclient.Message) error {
for _, block := range message.RevertedBlocks {
deleteBlocks = append(deleteBlocks, block.Number.Uint64())
if err := w.s.DeleteErrorLogsWithBlock(block.Hash); err != nil {
w.l.Infow("error when revert block", "blocks", deleteBlocks, "err", err)
return err
}
}
Expand Down
2 changes: 2 additions & 0 deletions v2/internal/server/tradelogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ func (s *TradeLogs) getTradeLogs(c *gin.Context) {
return
}

s.l.Infow("get trade log query", "query", query)

var data []storageTypes.TradeLog
for _, storage := range s.storage {
tradeLogs, err := storage.Get(query)
Expand Down
2 changes: 2 additions & 0 deletions v2/internal/worker/log_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func (w *LogParser) Publish(ctx context.Context, topic string, data interface{})
func (w *LogParser) processMessage(msg types.Message) error {
var deleteBlocks []uint64

w.l.Infow("process message", "msg", msg)

for _, block := range msg.RevertedBlocks {
deleteBlocks = append(deleteBlocks, block.Number.Uint64())
}
Expand Down

0 comments on commit 292f578

Please sign in to comment.