Epoch before era (#3509)
This commit is contained in:
parent
5b90e17dd6
commit
6b0450a725
@ -40,7 +40,7 @@ function DayItem ({ className, item: { date, info, type } }: Props): React.React
|
||||
? <div className='itemLink'><a href='#/democracy'>{t<string>('via Democracy')}</a></div>
|
||||
: ['societyChallenge', 'societyRotate'].includes(type)
|
||||
? <div className='itemLink'><a href='#/society'>{t<string>('via Society')}</a></div>
|
||||
: ['stakingEra', 'stakingSession'].includes(type)
|
||||
: ['stakingEpoch', 'stakingEra'].includes(type)
|
||||
? <div className='itemLink'><a href='#/staking'>{t<string>('via Staking')}</a></div>
|
||||
: ['stakingSlash'].includes(type)
|
||||
? <div className='itemLink'><a href='#/staking/slashes'>{t<string>('via Staking/Slashed')}</a></div>
|
||||
@ -74,12 +74,12 @@ function DayItem ({ className, item: { date, info, type } }: Props): React.React
|
||||
: t<string>('Execute anonymous scheduled task')
|
||||
}</div>{typeLink}</>;
|
||||
|
||||
case 'stakingEpoch':
|
||||
return <><div className='itemDesc'>{t<string>('Start of a new staking session {{id}}', { replace: { id } })}</div>{typeLink}</>;
|
||||
|
||||
case 'stakingEra':
|
||||
return <><div className='itemDesc'>{t<string>('Start of a new staking era {{id}}', { replace: { id } })}</div>{typeLink}</>;
|
||||
|
||||
case 'stakingSession':
|
||||
return <><div className='itemDesc'>{t<string>('Start of a new staking session {{id}}', { replace: { id } })}</div>{typeLink}</>;
|
||||
|
||||
case 'stakingSlash':
|
||||
return <><div className='itemDesc'>{t<string>('Application of slashes from era {{id}}', { replace: { id } })}</div>{typeLink}</>;
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
export type EntryType = 'councilElection' | 'councilMotion' | 'democracyDispatch' | 'democracyLaunch' | 'referendumDispatch' | 'referendumVote' | 'scheduler' | 'societyChallenge' | 'societyRotate'| 'stakingEra' | 'stakingSession' | 'stakingSlash' | 'treasurySpend';
|
||||
export type EntryType = 'councilElection' | 'councilMotion' | 'democracyDispatch' | 'democracyLaunch' | 'referendumDispatch' | 'referendumVote' | 'scheduler' | 'societyChallenge' | 'societyRotate'| 'stakingEpoch' | 'stakingEra' | 'stakingSlash' | 'treasurySpend';
|
||||
|
||||
export interface EntryInfo {
|
||||
blockNumber: BN;
|
||||
|
||||
@ -21,8 +21,8 @@ type SlashEntry = [{ args: [EraIndex] }, UnappliedSlash[]];
|
||||
|
||||
type ScheduleEntry = [{ args: [BlockNumber] }, Option<Scheduled>[]];
|
||||
|
||||
function newDate (remaining: BN, blockTime: number): DateExt {
|
||||
const date = new Date(Date.now() + remaining.muln(blockTime).toNumber());
|
||||
function newDate (blocks: BN, blockTime: number): DateExt {
|
||||
const date = new Date(Date.now() + blocks.muln(blockTime).toNumber());
|
||||
|
||||
return { date, dateTime: date.getTime() };
|
||||
}
|
||||
@ -106,8 +106,8 @@ function createReferendums (bestNumber: BlockNumber, blockTime: number, referend
|
||||
}
|
||||
|
||||
function createStakingInfo (bestNumber: BlockNumber, blockTime: number, sessionInfo: DeriveSessionProgress, unapplied: SlashEntry[], slashDeferDuration?: BlockNumber): [EntryType, EntryInfo[]][] {
|
||||
const remainingEra = sessionInfo.eraLength.sub(sessionInfo.eraProgress);
|
||||
const remainingSes = sessionInfo.sessionLength.sub(sessionInfo.sessionProgress);
|
||||
const blocksEra = sessionInfo.eraLength.sub(sessionInfo.eraProgress);
|
||||
const blocksSes = sessionInfo.sessionLength.sub(sessionInfo.sessionProgress);
|
||||
const slashDuration = slashDeferDuration?.mul(sessionInfo.eraLength);
|
||||
const slashEras = slashDuration
|
||||
? unapplied
|
||||
@ -128,20 +128,20 @@ function createStakingInfo (bestNumber: BlockNumber, blockTime: number, sessionI
|
||||
: [];
|
||||
|
||||
return [
|
||||
['stakingEpoch', [{
|
||||
...newDate(blocksSes, blockTime),
|
||||
blockNumber: bestNumber.add(blocksSes),
|
||||
blocks: blocksSes,
|
||||
info: sessionInfo.currentIndex.add(BN_ONE),
|
||||
type: 'stakingEpoch'
|
||||
}]],
|
||||
['stakingEra', [{
|
||||
...newDate(remainingEra, blockTime),
|
||||
blockNumber: bestNumber.add(remainingEra),
|
||||
blocks: remainingEra,
|
||||
...newDate(blocksEra, blockTime),
|
||||
blockNumber: bestNumber.add(blocksEra),
|
||||
blocks: blocksEra,
|
||||
info: sessionInfo.activeEra.add(BN_ONE),
|
||||
type: 'stakingEra'
|
||||
}]],
|
||||
['stakingSession', [{
|
||||
...newDate(remainingSes, blockTime),
|
||||
blockNumber: bestNumber.add(remainingSes),
|
||||
blocks: remainingSes,
|
||||
info: sessionInfo.currentIndex.add(BN_ONE),
|
||||
type: 'stakingSession'
|
||||
}]],
|
||||
['stakingSlash', slashEras]
|
||||
];
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user