From 7f32145840fd4729af1498521d1d99a7c96332b4 Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Wed, 1 May 2024 19:12:00 -0700 Subject: [PATCH] fix pr comments --- disperser/dataapi/queried_operators_handlers.go | 7 ++++--- disperser/dataapi/subgraph_client.go | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/disperser/dataapi/queried_operators_handlers.go b/disperser/dataapi/queried_operators_handlers.go index d19cfe6810..90596b8197 100644 --- a/disperser/dataapi/queried_operators_handlers.go +++ b/disperser/dataapi/queried_operators_handlers.go @@ -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) @@ -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 { diff --git a/disperser/dataapi/subgraph_client.go b/disperser/dataapi/subgraph_client.go index cc73bd5f5b..5665641503 100644 --- a/disperser/dataapi/subgraph_client.go +++ b/disperser/dataapi/subgraph_client.go @@ -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 {