Skip to content

Commit

Permalink
fix(eventindexer): add address to Slashed event in db, + add logs (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey authored Jul 4, 2023
1 parent 7f41353 commit 4ef8d0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions packages/eventindexer/http/get_pos_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/cyberhorsey/webutils"
"github.com/labstack/echo/v4"
"github.com/patrickmn/go-cache"
log "github.com/sirupsen/logrus"
)

type posStatsResponse struct {
Expand Down Expand Up @@ -47,6 +48,12 @@ func (srv *Server) getPosStats(ctx context.Context) (*posStatsResponse, error) {
return nil, err
}

log.Infof(
"pos stats, slashedTokens: %v, capacity: %v",
totalSlashedTokens.String(),
capacity.String(),
)

resp := &posStatsResponse{
TotalSlashedTokens: totalSlashedTokens.String(),
CurrentProtocolCapacity: capacity.String(),
Expand Down
7 changes: 4 additions & 3 deletions packages/eventindexer/indexer/save_slashed_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ func (svc *Service) saveSlashedEvents(
for {
event := events.Event

log.Infof("new slashed event, addr: %v", event.Addr.Hex())
log.Infof("new slashed event, addr: %v, amt: %v", event.Addr.Hex(), event.Amount)

if err := svc.saveSlashedEvent(ctx, chainID, event); err != nil {
eventindexer.SlashedEventsProcessedError.Inc()

return errors.Wrap(err, "svc.saveBlockVerifiedEvent")
return errors.Wrap(err, "svc.saveSlashedEvent")
}

if !events.Next() {
Expand All @@ -53,7 +53,8 @@ func (svc *Service) saveSlashedEvent(
Data: string(marshaled),
ChainID: chainID,
Event: eventindexer.EventNameSlashed,
Address: "",
Address: event.Addr.Hex(),
Amount: new(big.Int).SetUint64(event.Amount),
})
if err != nil {
return errors.Wrap(err, "svc.eventRepo.Save")
Expand Down

0 comments on commit 4ef8d0c

Please sign in to comment.