Skip to content

Commit

Permalink
Minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bobo-k2 committed Nov 27, 2024
1 parent c23ecbc commit d163423
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/hooks/useInflation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function useInflation(): UseInflation {
(standardErasPerBuildAndEarnPeriod + standardErasPerVotingPeriod);

// Estimate total issuance at the end of the current cycle.
const endOfCycleBlock = period1StartBlock + cycleLengthInBlocks;
const endOfCycleBlock = Math.max(period1StartBlock + cycleLengthInBlocks, currentBlock.value);

// Calculate realized inflation.
inflation =
Expand Down Expand Up @@ -141,15 +141,10 @@ export function useInflation(): UseInflation {

// One sample per era (take into consideration that voting era takes multiple standard era lengths).
let era = 0;
const getEraLength = (era: number, block: number): number => {
const len =
era === 1 || era % (standardErasPerBuildAndEarnPeriod + 2) === 0
? standardEraLength * standardErasPerVotingPeriod
: standardEraLength;

console.log(era, block, len);
return len;
};
const getEraLength = (era: number, block: number): number =>
era === 1 || era % (standardErasPerBuildAndEarnPeriod + 2) === 0
? standardEraLength * standardErasPerVotingPeriod
: standardEraLength;

for (let i = firstBlock - 1; i <= lastBlock; i += getEraLength(era, i)) {
const inflation =
Expand Down

0 comments on commit d163423

Please sign in to comment.