Skip to content
Snippets Groups Projects
Commit fce39279 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] `blockCount` crashed

parent 590dd993
No related branches found
No related tags found
No related merge requests found
...@@ -35,7 +35,7 @@ module.exports = async (req: any, res: any, next: any) => { ...@@ -35,7 +35,7 @@ module.exports = async (req: any, res: any, next: any) => {
// detect fork // detect fork
if ( blockchain.length > 0 ) if ( blockchain.length > 0 )
{ {
let newHashPreviousCurrentblock = (await dataFinder.getBlock(blockchain.length - 1) as { hash: string }).hash let newHashPreviousCurrentblock = (await dataFinder.getCurrentBlockOrNull() as { hash: string }).hash
if ( hashPreviousCurrentblock != newHashPreviousCurrentblock ) if ( hashPreviousCurrentblock != newHashPreviousCurrentblock )
{ {
blockchain.splice(0, blockchain.length); blockchain.splice(0, blockchain.length);
...@@ -65,7 +65,7 @@ module.exports = async (req: any, res: any, next: any) => { ...@@ -65,7 +65,7 @@ module.exports = async (req: any, res: any, next: any) => {
} }
// stock hashPreviousCurrentblock and previousBlockchainTime // stock hashPreviousCurrentblock and previousBlockchainTime
let tmpCurrentBlock = await dataFinder.getBlock(blockchain.length - 1) as DBBlock let tmpCurrentBlock = await dataFinder.getCurrentBlockOrNull() as DBBlock
hashPreviousCurrentblock = tmpCurrentBlock.hash; hashPreviousCurrentblock = tmpCurrentBlock.hash;
previousBlockchainTime = tmpCurrentBlock.medianTime; previousBlockchainTime = tmpCurrentBlock.medianTime;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment