Cater for at-genesis best headers (#3264)
This commit is contained in:
@@ -20,13 +20,13 @@
|
||||
"@polkadot/api": "4.0.1-8",
|
||||
"@polkadot/rpc-core": "4.0.1-8",
|
||||
"@polkadot/types": "4.0.1-8",
|
||||
"@polkadot/util": "^6.0.1-5",
|
||||
"@polkadot/util-crypto": "^6.0.1-5",
|
||||
"@polkadot/x-rxjs": "^6.0.1-5",
|
||||
"@polkadot/util": "^6.0.1-9",
|
||||
"@polkadot/util-crypto": "^6.0.1-9",
|
||||
"@polkadot/x-rxjs": "^6.0.1-9",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.0.1-5",
|
||||
"@polkadot/keyring": "^6.0.1-9",
|
||||
"@polkadot/rpc-provider": "4.0.1-8"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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