Created
February 6, 2018 19:49
-
-
Save nosequeldeebee/2fadb1ccb5da8307df9bd614bfb9524b 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
// make sure block is valid by checking index, and comparing the hash of the previous block | |
func isBlockValid(newBlock, oldBlock Block) bool { | |
if oldBlock.Index+1 != newBlock.Index { | |
return false | |
} | |
if oldBlock.Hash != newBlock.PrevHash { | |
return false | |
} | |
if calculateHash(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