Limit to maximum hashes (250) in era length calcs (#2910)

This commit is contained in:
Jaco Greeff
2020-12-03 09:45:23 +01:00
committed by GitHub
parent 96f32c63fd
commit 1d6bfb69ff
+8 -5
View File
@@ -10,7 +10,7 @@ import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { isNumber, isUndefined } from '@polkadot/util';
import { FALLBACK_PERIOD, MAX_FINALITY_LAG, MORTAL_PERIOD } from './constants';
import { FALLBACK_MAX_HASH_COUNT, FALLBACK_PERIOD, MAX_FINALITY_LAG, MORTAL_PERIOD } from './constants';
interface Result {
header: Header | null;
@@ -63,10 +63,13 @@ export function signingInfo (_instanceId: string, api: ApiInterfaceRx): (address
]).pipe(
map(([nonce, header]) => ({
header,
mortalLength: MORTAL_PERIOD
.div(api.consts.babe?.expectedBlockTime || api.consts.timestamp?.minimumPeriod.muln(2) || FALLBACK_PERIOD)
.iadd(MAX_FINALITY_LAG)
.toNumber(),
mortalLength: Math.min(
FALLBACK_MAX_HASH_COUNT,
MORTAL_PERIOD
.div(api.consts.babe?.expectedBlockTime || api.consts.timestamp?.minimumPeriod.muln(2) || FALLBACK_PERIOD)
.iadd(MAX_FINALITY_LAG)
.toNumber()
),
nonce
}))
);