Created
February 24, 2017 22:13
-
-
Save lhartikk/bfc392a9d0156582de42b0d8fa2a0d5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isValidNewBlock = (newBlock, previousBlock) => { | |
if (previousBlock.index + 1 !== newBlock.index) { | |
console.log('invalid index'); | |
return false; | |
} else if (previousBlock.hash !== newBlock.previousHash) { | |
console.log('invalid previoushash'); | |
return false; | |
} else if (calculateHashForBlock(newBlock) !== newBlock.hash) { | |
console.log('invalid hash: ' + calculateHashForBlock(newBlock) + ' ' + newBlock.hash); | |
return false; | |
} | |
return true; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment