mirror of
				https://github.com/hackku21/loc-chain-backend.git
				synced 2025-06-13 12:53:59 +00:00 
			
		
		
		
	Add debug output
This commit is contained in:
		
							parent
							
								
									7fcde77bbe
								
							
						
					
					
						commit
						63a172209c
					
				| @ -224,6 +224,7 @@ export class Blockchain extends Unit { | ||||
|      */ | ||||
|     public async getPeerSubmit(peer: Peer): Promise<Block[] | undefined> { | ||||
|         try { | ||||
|             this.logging.verbose(`Making request to: ${peer.host}api/v1/chain/submit`) | ||||
|             const result = await fetch(`${peer.host}api/v1/chain/submit`).then(res => res.json()) | ||||
|             const blocks: unknown = result.data?.data?.records | ||||
|             if ( Array.isArray(blocks) && blocks.every(block => { | ||||
| @ -319,11 +320,16 @@ export class Blockchain extends Unit { | ||||
|         this.logging.debug('Called refresh().') | ||||
| 
 | ||||
|         const peers = this.getPeers() | ||||
|         this.logging.debug({peers}) | ||||
| 
 | ||||
|         let longestChain: Block[] = [] | ||||
|         const chains = await Promise.all( | ||||
|             peers.map(peer => this.getPeerSubmit(peer)) | ||||
|         ) | ||||
| 
 | ||||
|         this.logging.debug('Got peer chain info:') | ||||
|         this.logging.debug(chains) | ||||
| 
 | ||||
|         for ( const chain of chains ) { | ||||
|             if ( | ||||
|                 chain | ||||
| @ -331,6 +337,8 @@ export class Blockchain extends Unit { | ||||
|                 && await this.validate(chain) | ||||
|             ) { | ||||
|                 longestChain = chain | ||||
|             } else { | ||||
|                 this.logging.debug('Failed validation!') | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user