Use the parent header for era info (#3260)

This commit is contained in:
Jaco Greeff
2021-03-04 08:57:22 +01:00
committed by GitHub
parent 67b416fe80
commit e117619e34
+9 -3
View File
@@ -33,10 +33,16 @@ function nextNonce (api: ApiInterfaceRx, address: string): Observable<Index> {
function signingHeader (api: ApiInterfaceRx): Observable<Header> {
return combineLatest([
api.rpc.chain.getHeader(),
api.rpc.chain.getFinalizedHead().pipe(
switchMap((hash) => api.rpc.chain.getHeader(hash))
)
api.rpc.chain.getFinalizedHead()
]).pipe(
switchMap(([{ parentHash }, finHash]) =>
// retrieve the headers - in the case of the current block, we use the parent
// to minimize (not completely remove) the impact that forks do have on the system
combineLatest([
api.rpc.chain.getHeader(parentHash),
api.rpc.chain.getHeader(finHash)
])
),
map(([current, finalized]) =>
// determine the hash to use, current when lag > max, else finalized
current.number.unwrap().sub(finalized.number.unwrap()).gt(MAX_FINALITY_LAG)