Skip to content

Commit

Permalink
fix pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth More authored and Siddharth More committed May 2, 2024
1 parent 8c7a90b commit 7f32145
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions disperser/dataapi/queried_operators_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ func (s *server) getDeregisteredOperatorForDays(ctx context.Context, days int32)
return DeregisteredOperatorMetadata, nil
}

// Function to get registered operators for a given number of days
func (s *server) getRegisteredOperatorForDays(ctx context.Context, days int32) ([]*QueriedStateOperatorMetadata, error) {
// Track time taken to get deregistered operators
// Track time taken to get registered operators
startTime := time.Now()

indexedRegisteredOperatorState, err := s.subgraphClient.QueryIndexedOperatorsWithStateForTimeWindow(ctx, days, Registered)
Expand Down Expand Up @@ -87,8 +88,8 @@ func (s *server) getRegisteredOperatorForDays(ctx context.Context, days int32) (
return RegisteredOperatorMetadata, nil
}

func processOperatorOnlineCheck(deregisteredOperatorState *IndexedQueriedOperatorInfo, operatorOnlineStatusresultsChan chan<- *QueriedStateOperatorMetadata, logger logging.Logger) {
operators := deregisteredOperatorState.Operators
func processOperatorOnlineCheck(queriedOperatorsInfo *IndexedQueriedOperatorInfo, operatorOnlineStatusresultsChan chan<- *QueriedStateOperatorMetadata, logger logging.Logger) {
operators := queriedOperatorsInfo.Operators
wp := workerpool.New(poolSize)

for _, operatorInfo := range operators {
Expand Down
6 changes: 3 additions & 3 deletions disperser/dataapi/subgraph_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,26 +243,26 @@ func (sc *subgraphClient) QueryOperatorQuorumEvent(ctx context.Context, startBlo
}

func (sc *subgraphClient) QueryIndexedOperatorsWithStateForTimeWindow(ctx context.Context, days int32, state OperatorState) (*IndexedQueriedOperatorInfo, error) {
// Query all deregistered operators in the last N days.
// Query all operators in the last N days.
lastNDayInSeconds := uint64(time.Now().Add(-time.Duration(days) * 24 * time.Hour).Unix())
var operators map[core.OperatorID]*QueriedOperatorInfo
if state == Deregistered {
// Get OperatorsInfo for DeRegistered Operators
deregisteredOperators, err := sc.api.QueryDeregisteredOperatorsGreaterThanBlockTimestamp(ctx, lastNDayInSeconds)
if err != nil {
return nil, err
}

operators = make(map[core.OperatorID]*QueriedOperatorInfo, len(deregisteredOperators))
// Get OpeatroInfo for DeRegistered Operators
getOperatorInfoForQueriedOperators(sc, ctx, operators, deregisteredOperators)
} else if state == Registered {
// Get OperatorsInfo for Registered Operators
registeredOperators, err := sc.api.QueryRegisteredOperatorsGreaterThanBlockTimestamp(ctx, lastNDayInSeconds)
if err != nil {
return nil, err
}

operators = make(map[core.OperatorID]*QueriedOperatorInfo, len(registeredOperators))
// Get OpeatroInfo for DeRegistered Operators
getOperatorInfoForQueriedOperators(sc, ctx, operators, registeredOperators)

} else {
Expand Down

0 comments on commit 7f32145

Please sign in to comment.