@@ -312,7 +312,7 @@ export class Blockchain implements BlockchainInterface {
312312 return this . runWithLock < Block > ( async ( ) => {
313313 // if the head is not found return the genesis hash
314314 const hash = this . _heads [ name ] ?? this . genesisBlock . hash ( )
315- const block = await this . _getBlock ( hash )
315+ const block = await this . getBlock ( hash )
316316 return block
317317 } )
318318 }
@@ -333,7 +333,7 @@ export class Blockchain implements BlockchainInterface {
333333 // if the head is not found return the headHeader
334334 const hash = this . _heads [ name ] ?? this . _headBlockHash
335335 if ( hash === undefined ) throw new Error ( 'No head found.' )
336- const block = await this . _getBlock ( hash )
336+ const block = await this . getBlock ( hash )
337337 return block
338338 } )
339339 }
@@ -344,7 +344,7 @@ export class Blockchain implements BlockchainInterface {
344344 async getCanonicalHeadHeader ( ) : Promise < BlockHeader > {
345345 return this . runWithLock < BlockHeader > ( async ( ) => {
346346 if ( ! this . _headHeaderHash ) throw new Error ( 'No head header set' )
347- const block = await this . _getBlock ( this . _headHeaderHash )
347+ const block = await this . getBlock ( this . _headHeaderHash )
348348 return block . header
349349 } )
350350 }
@@ -355,7 +355,7 @@ export class Blockchain implements BlockchainInterface {
355355 async getCanonicalHeadBlock ( ) : Promise < Block > {
356356 return this . runWithLock < Block > ( async ( ) => {
357357 if ( ! this . _headBlockHash ) throw new Error ( 'No head block set' )
358- return this . _getBlock ( this . _headBlockHash )
358+ return this . getBlock ( this . _headBlockHash )
359359 } )
360360 }
361361
@@ -704,13 +704,6 @@ export class Blockchain implements BlockchainInterface {
704704 // in the `VM` if we encounter a `BLOCKHASH` opcode: then a bigint is used we
705705 // need to then read the block from the canonical chain Q: is this safe? We
706706 // know it is OK if we call it from the iterator... (runBlock)
707- return this . _getBlock ( blockId )
708- }
709-
710- /**
711- * @hidden
712- */
713- private async _getBlock ( blockId : Buffer | number | bigint ) {
714707 return this . dbManager . getBlock ( blockId )
715708 }
716709
@@ -745,7 +738,7 @@ export class Blockchain implements BlockchainInterface {
745738 const nextBlock = async ( blockId : Buffer | bigint | number ) : Promise < any > => {
746739 let block
747740 try {
748- block = await this . _getBlock ( blockId )
741+ block = await this . getBlock ( blockId )
749742 } catch ( error : any ) {
750743 if ( error . code !== 'LEVEL_NOT_FOUND' ) {
751744 throw error
@@ -931,14 +924,14 @@ export class Blockchain implements BlockchainInterface {
931924
932925 while ( maxBlocks !== blocksRanCounter ) {
933926 try {
934- let nextBlock = await this . _getBlock ( nextBlockNumber )
927+ let nextBlock = await this . getBlock ( nextBlockNumber )
935928 const reorg = lastBlock ? ! lastBlock . hash ( ) . equals ( nextBlock . header . parentHash ) : false
936929 if ( reorg ) {
937930 // If reorg has happened, the _heads must have been updated so lets reload the counters
938931 headHash = this . _heads [ name ] ?? this . genesisBlock . hash ( )
939932 headBlockNumber = await this . dbManager . hashToNumber ( headHash )
940933 nextBlockNumber = headBlockNumber + BigInt ( 1 )
941- nextBlock = await this . _getBlock ( nextBlockNumber )
934+ nextBlock = await this . getBlock ( nextBlockNumber )
942935 }
943936 this . _heads [ name ] = nextBlock . hash ( )
944937 lastBlock = nextBlock
@@ -991,7 +984,7 @@ export class Blockchain implements BlockchainInterface {
991984 if ( ! this . _headHeaderHash ) throw new Error ( 'No head header set' )
992985 const ancestorHeaders = new Set < BlockHeader > ( )
993986
994- let { header } = await this . _getBlock ( this . _headHeaderHash )
987+ let { header } = await this . getBlock ( this . _headHeaderHash )
995988 if ( header . number > newHeader . number ) {
996989 header = await this . getCanonicalHeader ( newHeader . number )
997990 ancestorHeaders . add ( header )
0 commit comments