Skip to content

Instantly share code, notes, and snippets.

@lhartikk
Created February 24, 2017 21:33
Show Gist options
  • Save lhartikk/9029e732712345d17db90f005817f466 to your computer and use it in GitHub Desktop.
Save lhartikk/9029e732712345d17db90f005817f466 to your computer and use it in GitHub Desktop.
var generateNextBlock = (blockData) => {
var previousBlock = getLatestBlock();
var nextIndex = previousBlock.index + 1;
var nextTimestamp = new Date().getTime() / 1000;
var nextHash = calculateHash(nextIndex, previousBlock.hash, nextTimestamp, blockData);
return new Block(nextIndex, previousBlock.hash, nextTimestamp, blockData, nextHash);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment