currentDistributionCycle
Returns the distribution cycle at poxInfo.currentBurnchainBlockHeight. Pure computation that mirrors the pox-5 read-only current-distribution-cycle without a request.
Usage
import {
currentDistributionCycle,
distributionCycleToBurnHeight,
fetchLastRewardComputeHeight,
fetchPoxInfo,
} from '@stacks/bitcoin-staking';
const poxInfo = await fetchPoxInfo({ network: 'mainnet' });
const distributionCycle = currentDistributionCycle(poxInfo);
const calculationHeight = distributionCycleToBurnHeight({ distributionCycle, poxInfo }) - 1;
const lastComputed = await fetchLastRewardComputeHeight({ network: 'mainnet' });
const rewardsPending = calculationHeight > lastComputed;Notes
Same as burnHeightToDistributionIndex with
burnHeight: poxInfo.currentBurnchainBlockHeight. The result is only as current aspoxInfo.calculate-rewardssettles at the last block of the previous distribution cycle: the current cycle's start height minus 1. It fails withERR_DISTRIBUTION_ALREADY_COMPUTED (u30)once that height has been computed.Throws an
Errorwith the messageburnHeight is before first-burnchain-block-heightif the current height is belowpoxInfo.firstBurnchainBlockHeight.
Signature
Returns
number
The current distribution cycle index.
Parameters
poxInfo (required)
Type:
PoxInfo
A PoxInfo, usually from fetchPoxInfo.
Was this helpful?