mirror of
				https://github.com/hackku21/loc-chain-backend.git
				synced 2025-06-13 12:53:59 +00:00 
			
		
		
		
	Fid Blockchain.validate for genesis blocks
This commit is contained in:
		
							parent
							
								
									0cb78fef35
								
							
						
					
					
						commit
						0580d2274f
					
				| @ -272,6 +272,10 @@ export class Blockchain extends Unit { | ||||
|         const blocks = collect<Block>(chain) | ||||
|         return ( | ||||
|             await blocks.promiseMap(async (block, idx) => { | ||||
|                 if ( await block.isGenesis() ) { | ||||
|                     return true | ||||
|                 } | ||||
| 
 | ||||
|                 const previous: Block | undefined = blocks.at(idx - 1) | ||||
|                 if ( !previous ) { | ||||
|                     this.logging.debug(`Chain is invalid: block ${idx} is missing previous ${idx - 1}.`) | ||||
| @ -295,10 +299,6 @@ export class Blockchain extends Unit { | ||||
|                     return false | ||||
|                 } | ||||
| 
 | ||||
|                 if ( await block.isGenesis() ) { | ||||
|                     return true | ||||
|                 } | ||||
| 
 | ||||
|                 if ( !(await this.validateProofOfWork(block, previous)) ) { | ||||
|                     this.logging.debug(`Chain is invalid: block ${idx} failed proof of work validation`) | ||||
|                     return false; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user