Skip to content

Commit

Permalink
skip error if we could not find cyber links in tx events when process…
Browse files Browse the repository at this point in the history
…ing wasm module
Victor Neznaykin committed Nov 13, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 6a7368c commit 2acd4f3
Showing 3 changed files with 22 additions and 5 deletions.
10 changes: 7 additions & 3 deletions delivery/server/scraper.go
Original file line number Diff line number Diff line change
@@ -43,6 +43,8 @@ func (s *Server) startMetricsScrapper() {
statusMap map[string]int
ctx = context.Background()
ticker = time.NewTicker(1 * time.Minute)
blocks []*model.Block
err error
)

defer ticker.Stop()
@@ -53,10 +55,11 @@ func (s *Server) startMetricsScrapper() {
s.log.Info().Msg("stop metrics scraper")
return
case <-ticker.C:
if err := s.storage.Ping(ctx); err != nil {
if err = s.storage.Ping(ctx); err != nil {
continue
}
blocks, err := s.storage.GetAllBlocks(ctx)

blocks, err = s.storage.GetAllBlocks(ctx)
if err != nil {
s.log.Error().Err(err).Msg("can't get all blocks from storage")
continue
@@ -82,7 +85,8 @@ func (s *Server) startMetricsScrapper() {
statusMetric.With(prometheus.Labels{"status": statusName}).Set(float64(count))
}

count, err := s.storage.CountErrorMessages(ctx)
var count int64
count, err = s.storage.CountErrorMessages(ctx)
if err != nil {
s.log.Error().Err(err).Msg("can't get count of error messages")
continue
12 changes: 12 additions & 0 deletions modules/wasm/message.go
Original file line number Diff line number Diff line change
@@ -26,6 +26,18 @@ func (m *Module) HandleMessage(ctx context.Context, index int, bostromMsg sdk.Ms
return nil
}

if err := m.findAndPublishCyberLink(ctx, tx, index); err != nil {
if errors.Is(err, types.ErrNoEventFound) || errors.Is(err, types.ErrNoAttributeFound) {
return nil
}

return err
}

return nil
}

func (m *Module) findAndPublishCyberLink(ctx context.Context, tx *types.Tx, index int) error {
event, err := tx.FindEventByType(index, graph.EventTypeCyberlink)
if err != nil {
return err
5 changes: 3 additions & 2 deletions types/cosmos.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,8 @@ import (
)

var (
ErrNoEventFound = errors.New("no event found")
ErrNoEventFound = errors.New("no event found")
ErrNoAttributeFound = errors.New("no event with attribute")
)

type (
@@ -206,7 +207,7 @@ func (tx Tx) FindAttributeByKey(event sdk.StringEvent, attrKey string) (string,
}
}

return "", errors.New(fmt.Sprintf("no event with attribute %s found inside tx with hash %s", attrKey, tx.TxHash))
return "", fmt.Errorf("%w: %s found inside tx with hash %s", ErrNoAttributeFound, attrKey, tx.TxHash)
}

// Successful tells whether this tx is successful or not

0 comments on commit 2acd4f3

Please sign in to comment.