async validateBlock (blockHeight) {
    // get block object
    let block = await this.getBlock(blockHeight)
    // get block hash
    let blockHash = block.hash
    // remove block hash to test block integrity
    block.hash = ''

    // generate block hash
    let validBlockHash = SHA256(JSON.stringify(block)).toString()

    // Compare
    if (blockHash === validBlockHash) {
      // return true if block is valid
      return true
    } else {
      console.log('Block #' + blockHeight + ' invalid hash:\n' + blockHash + '<>' + validBlockHash)
      return false
    }
  }
// CRITERION: Modify the validateBlock() function to validate a block stored within levelDB
Modify the validateBlock() function to validate a block stored within levelDB
Modify the validateBlock () function to validate a block stored within levelDB
async validateBlock (blockHeight) {
    let block = await this.getBlock(blockHeight)
    let blockHash = block.hash
    block.hash = ''
    let validBlockHash = SHA256(JSON.stringify(block)).toString()
    if (blockHash === validBlockHash) {
      return true
    } else {
      console.log('Block #' + blockHeight + ' invalid hash:\n' + blockHash + '<>' + validBlockHash)
      return false
    }
  }
async validateBlock ( blockHeight ) { let block = await this . getBlock ( blockHeight ) let blockHash = block . hash block . hash = '' let validBlockHash = SHA256 ( JSON . stringify ( block ) ) . toString ( ) if ( blockHash === validBlockHash ) { return true } else { console . log ( 'Block #' + blockHeight + ' invalid hash:\n' + blockHash + '<>' + validBlockHash ) return false } }
CRITERION: Modify the validateBlock() function to validate a block stored within levelDB
CRITERION : Modify the validateBlock () function to validate a block stored within levelDB
// get block object // get block hash // remove block hash to test block integrity // generate block hash // Compare // return true if block is valid