async validateChain () {
    let errorLog = []
    let blockChainHeight = await this.getBlockHeight()

    for (let i = 0; i < blockChainHeight; i++) {

      // validate a single block
      if (!this.validateBlock(i)) errorLog.push(i)

      // compare blocks hash link
      let blockHash = this.getBlock(i).hash
      let previousHash = this.getBlock(i + 1).previousBlockHash
      if (blockHash !== previousHash) {
        errorLog.push(i)
      }

    }

    if (errorLog.length > 0) {
      console.log('Block errors = ' + errorLog.length)
      console.log('Blocks: ' + errorLog)
    } else {
      console.log('No errors detected')
    }

  }
// CRITERION: Modify the validateChain() function to validate blockchain stored within levelDB
Modify the validateChain() function to validate blockchain stored within levelDB
Modify the validateChain () function to validate blockchain stored within levelDB
async validateChain () {
    let errorLog = []
    let blockChainHeight = await this.getBlockHeight()
    for (let i = 0; i < blockChainHeight; i++) {
      if (!this.validateBlock(i)) errorLog.push(i)
      let blockHash = this.getBlock(i).hash
      let previousHash = this.getBlock(i + 1).previousBlockHash
      if (blockHash !== previousHash) {
        errorLog.push(i)
      }
    }
    if (errorLog.length > 0) {
      console.log('Block errors = ' + errorLog.length)
      console.log('Blocks: ' + errorLog)
    } else {
      console.log('No errors detected')
    }
  }
async validateChain ( ) { let errorLog = [ ] let blockChainHeight = await this . getBlockHeight ( ) for ( let i = 0 ; i < blockChainHeight ; i ++ ) { if ( ! this . validateBlock ( i ) ) errorLog . push ( i ) let blockHash = this . getBlock ( i ) . hash let previousHash = this . getBlock ( i + 1 ) . previousBlockHash if ( blockHash !== previousHash ) { errorLog . push ( i ) } } if ( errorLog . length > 0 ) { console . log ( 'Block errors = ' + errorLog . length ) console . log ( 'Blocks: ' + errorLog ) } else { console . log ( 'No errors detected' ) } }
CRITERION: Modify the validateChain() function to validate blockchain stored within levelDB
CRITERION : Modify the validateChain () function to validate blockchain stored within levelDB
// validate a single block // compare blocks hash link