async addBlock (newBlock) {
    // previous block height
    let previousBlockHeight = parseInt(await this.getBlockHeight())
    // Block height
    newBlock.height = previousBlockHeight + 1
    // UTC timestamp
    newBlock.time = new Date().getTime().toString().slice(0, -3)
    // previous block hash
    if (newBlock.height > 0) {
      let previousBlock = await this.getBlock(previousBlockHeight)
      newBlock.previousBlockHash = previousBlock.hash
    }
    // Block hash with SHA256 using newBlock and converting to a string
    newBlock.hash = SHA256(JSON.stringify(newBlock)).toString()

    // Adding block object to levelDB
    await this.addLevelDBData(newBlock.height, JSON.stringify(newBlock))
  }
// CRITERION: addBlock(newBlock) function includes a method to store newBlock with LevelDB.
addBlock(newBlock) function includes a method to store newBlock with LevelDB.
addBlock ( newBlock ) function includes a method to store newBlock with LevelDB .
async addBlock (newBlock) {
    let previousBlockHeight = parseInt(await this.getBlockHeight())
    newBlock.height = previousBlockHeight + 1
    newBlock.time = new Date().getTime().toString().slice(0, -3)
    if (newBlock.height > 0) {
      let previousBlock = await this.getBlock(previousBlockHeight)
      newBlock.previousBlockHash = previousBlock.hash
    }
    newBlock.hash = SHA256(JSON.stringify(newBlock)).toString()
    await this.addLevelDBData(newBlock.height, JSON.stringify(newBlock))
  }
async addBlock ( newBlock ) { let previousBlockHeight = parseInt ( await this . getBlockHeight ( ) ) newBlock . height = previousBlockHeight + 1 newBlock . time = new Date ( ) . getTime ( ) . toString ( ) . slice ( 0 , - 3 ) if ( newBlock . height > 0 ) { let previousBlock = await this . getBlock ( previousBlockHeight ) newBlock . previousBlockHash = previousBlock . hash } newBlock . hash = SHA256 ( JSON . stringify ( newBlock ) ) . toString ( ) await this . addLevelDBData ( newBlock . height , JSON . stringify ( newBlock ) ) }
CRITERION: addBlock(newBlock) function includes a method to store newBlock with LevelDB.
CRITERION : addBlock ( newBlock ) function includes a method to store newBlock with LevelDB .
// previous block height // Block height // UTC timestamp // previous block hash // Block hash with SHA256 using newBlock and converting to a string // Adding block object to levelDB