Cater for at-genesis best headers (#3264)
This commit is contained in:
@@ -35,13 +35,16 @@ function signingHeader (api: ApiInterfaceRx): Observable<Header> {
|
||||
api.rpc.chain.getHeader(),
|
||||
api.rpc.chain.getFinalizedHead()
|
||||
]).pipe(
|
||||
switchMap(([{ parentHash }, finHash]) =>
|
||||
switchMap(([bestHeader, 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)
|
||||
])
|
||||
// (when at genesis, just return the current header as the last known)
|
||||
bestHeader.parentHash.isEmpty
|
||||
? of([bestHeader, bestHeader])
|
||||
: combineLatest([
|
||||
api.rpc.chain.getHeader(bestHeader.parentHash),
|
||||
api.rpc.chain.getHeader(finHash)
|
||||
])
|
||||
),
|
||||
map(([current, finalized]) =>
|
||||
// determine the hash to use, current when lag > max, else finalized
|
||||
|
||||
Reference in New Issue
Block a user