Skip to content

Commit

Permalink
V6/bug fix/scoring function result (#2914)
Browse files Browse the repository at this point in the history
* fix score function return type

* convert linearSum return type to number

---------

Co-authored-by: djordjekovac <djordje.kovacevic@origin-trail.com>
  • Loading branch information
zeroxbt and djordjekovac authored Feb 2, 2024
1 parent 45744fa commit 2039e20
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/service/proximity-scoring-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,10 @@ class ProximityScoringService {
const dividend = mappedStake.pow(stakeExponent).mul(a).add(b);
const divisor = mappedDistance.pow(distanceExponent).mul(c).add(d);

return {
mappedDistance,
mappedStake,
score: Math.floor(
Number(multiplier) *
Math.log2(
Number(logArgumentConstant) + dividend.toNumber() / divisor.toNumber(),
),
),
};
return Math.floor(
Number(multiplier) *
Math.log2(Number(logArgumentConstant) + dividend.toNumber() / divisor.toNumber()),
);
}

async linearSum(
Expand Down Expand Up @@ -197,7 +191,7 @@ class ProximityScoringService {
finalScore = finalScore.mod(UINT40_MAX_BN.add(1));
}

return finalScore;
return finalScore.toNumber();
}
}

Expand Down

0 comments on commit 2039e20

Please sign in to comment.