Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshvanahalli committed Oct 25, 2023
1 parent 0e9445d commit 70df6d6
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions wsbroadcastserver/wsbroadcastserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,18 @@ func (s *WSBroadcastServer) Start(ctx context.Context) error {
HTTPHeaderChainId: []string{strconv.FormatUint(s.chainId, 10)},
})

return s.StartWithHeader(ctx, header)
startTime := time.Now()
err := s.StartWithHeader(ctx, header)
elapsed := time.Since(startTime)
startWithHeaderTimer.Update(elapsed)

if err != nil {
return err
}
return nil
}

func (s *WSBroadcastServer) StartWithHeader(ctx context.Context, header ws.HandshakeHeader) error {
startTimeMain := time.Now()
s.startMutex.Lock()
defer s.startMutex.Unlock()
if s.started {
Expand Down Expand Up @@ -490,9 +497,6 @@ func (s *WSBroadcastServer) StartWithHeader(ctx context.Context, header ws.Hands

s.started = true

elapsedMain := time.Since(startTimeMain)
startWithHeaderTimer.Update(elapsedMain)

return nil
}

Expand Down

0 comments on commit 70df6d6

Please sign in to comment.