From 52e4e0c838d3cef102a3276383785e689e6be176 Mon Sep 17 00:00:00 2001 From: Bogdan Rosianu Date: Tue, 26 Sep 2023 14:35:58 +0300 Subject: [PATCH] fixes after second review --- observer/mapCounters/mapCountersHolder.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/observer/mapCounters/mapCountersHolder.go b/observer/mapCounters/mapCountersHolder.go index df9fc167..de4748d2 100644 --- a/observer/mapCounters/mapCountersHolder.go +++ b/observer/mapCounters/mapCountersHolder.go @@ -34,30 +34,28 @@ func NewMapCountersHolder() *mapCountersHolder { // ComputeShardPosition returns the shard position based on the availability and the shard func (mch *mapCountersHolder) ComputeShardPosition(availability data.ObserverDataAvailabilityType, shardID uint32, numNodes uint32) (uint32, error) { + if numNodes == 0 { + return 0, errNumNodesMustBeGreaterThanZero + } counterMap, exists := mch.countersMap[availability] if !exists { return 0, errInvalidAvailability } - if numNodes == 0 { - return 0, errNumNodesMustBeGreaterThanZero - } - position := counterMap.computePositionForShard(shardID, numNodes) return position, nil } // ComputeAllNodesPosition returns the all nodes position based on the availability func (mch *mapCountersHolder) ComputeAllNodesPosition(availability data.ObserverDataAvailabilityType, numNodes uint32) (uint32, error) { + if numNodes == 0 { + return 0, errNumNodesMustBeGreaterThanZero + } counterMap, exists := mch.countersMap[availability] if !exists { return 0, errInvalidAvailability } - if numNodes == 0 { - return 0, errNumNodesMustBeGreaterThanZero - } - position := counterMap.computePositionForAllNodes(numNodes) return position, nil }