Skip to content

Commit

Permalink
Tradelogs parsing log error metrics (#94)
Browse files Browse the repository at this point in the history
* refactor log order

* fix spelling

---------

Co-authored-by: minhthanh.vu <[email protected]>
  • Loading branch information
linhnt3400 and ngocthanh1389 authored Nov 5, 2024
1 parent 4e7f63b commit f4f62bc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions internal/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ func (w *Worker) processMessages(m []evmlistenerclient.Message) error {
}
order, err := ps.Parse(ethLog, block.Timestamp)
if err != nil {
w.l.Errorw("error when parse log", "log", log, "order", order, "err", err)
if err = metrics.RecordCounter(context.Background(), ParsingErrorMetricName, 1); err != nil {
w.l.Errorw("error when record parsing error", "err", err)
}
w.l.Errorw("error when parse log", "log", log, "order", order, "err", err)
if err := w.s.InsertErrorLog(storage.EVMLog{
Address: log.Address,
Topics: strings.Join(log.Topics, ","),
Expand Down Expand Up @@ -168,10 +168,10 @@ func (w *Worker) retryParseLog() error {
}
order, err := ps.Parse(ethLog, l.Time)
if err != nil {
w.l.Errorw("error when retry log", "log", l, "err", err)
if err := metrics.RecordCounter(context.Background(), ParsingErrorMetricName, 1); err != nil {
w.l.Errorw("error when record parsing error", "err", err)
}
w.l.Errorw("error when retry log", "log", l, "err", err)
continue
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/parser/pancakeswap/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func hasFillingRights(exclusive, sender common.Address, exclusivityEndTime, bloc
}

func (p *Parser) Exchange() string {
return parser.ExPancackeSwap
return parser.ExPancakeSwap
}

func (p *Parser) UseTraceCall() bool {
Expand All @@ -306,11 +306,11 @@ func (p *Parser) ParseWithCallFrame(callFrame types.CallFrame, log ethereumTypes
}

func (p *Parser) LogFromExchange(log ethereumTypes.Log) bool {
return strings.EqualFold(log.Address.String(), parser.AddrPancakewap) &&
return strings.EqualFold(log.Address.String(), parser.AddrPancakeswap) &&
len(log.Topics) > 0 &&
strings.EqualFold(log.Topics[0].String(), p.eventHash)
}

func (p *Parser) Address() string {
return parser.AddrPancakewap
return parser.AddrPancakeswap
}
4 changes: 2 additions & 2 deletions pkg/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
ExNative = "native"
ExBebop = "bebop"
ExUniswapXV1 = "uniswapxV1"
ExPancackeSwap = "pancakeswap"
ExPancakeSwap = "pancakeswap"

Addr1InchV6 = "0x111111125421cA6dc452d289314280a0f8842A65"
AddrBebop = "0xbbbbbBB520d69a9775E85b458C58c648259FAD5F"
Expand All @@ -37,7 +37,7 @@ const (
AddrUniswapXV1 = "0x6000da47483062A0D734Ba3dc7576Ce6A0B645C4"
Addr0x = "0xDef1C0ded9bec7F1a1670819833240f027b25EfF"
Deployer0xV3 = "0x00000000000004533Fe15556B1E086BB1A72cEae"
AddrPancakewap = "0x35db01D1425685789dCc9228d47C7A5C049388d8"
AddrPancakeswap = "0x35db01D1425685789dCc9228d47C7A5C049388d8"
AddrParaswapTaker = "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57"
)

Expand Down

0 comments on commit f4f62bc

Please sign in to comment.