Skip to content

Commit

Permalink
fix: dev: pos-452 test-3 log event type
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcello Ardizzone committed Jun 3, 2022
1 parent 77ac5f0 commit b1c3522
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions bridge/setu/util/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"github.com/maticnetwork/bor/accounts/abi"
"io/ioutil"
"net/http"
"net/url"
"os"
"reflect"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -481,16 +481,22 @@ func GetUnconfirmedTxnCount() int {
return count
}

// LogElapsedTimeForStateSyncedEvent logs useful info if event is of type statesender.StatesenderStateSynced
// LogElapsedTimeForStateSyncedEvent logs useful info for StateSynced events
func LogElapsedTimeForStateSyncedEvent(event interface{}, functionName string, startTime time.Time) {
switch event.(type) {
case statesender.StatesenderStateSynced:
case statesender.StatesenderStateSynced, *statesender.StatesenderStateSyncedIterator:
event := event.(statesender.StatesenderStateSynced)
logger.Info("StateSyncedEvent: "+functionName,
"stateSyncId", event.Id,
"timeElapsed", time.Now().Sub(startTime).Milliseconds())
case *abi.Event:
event := event.(abi.Event)
if event.String() == "StateSynced" {
logger.Info("StateSyncedEvent-ABIEvent: "+functionName,
"stateSyncId", event.Id,
"timeElapsed", time.Now().Sub(startTime).Milliseconds())
}
default:
logger.Info("Different type", "type", reflect.TypeOf(event))
// do nothing
}

Expand Down

0 comments on commit b1c3522

Please sign in to comment.