Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing previous block hash? #5

Closed
Jaked222 opened this issue Jan 31, 2018 · 1 comment
Closed

Missing previous block hash? #5

Jaked222 opened this issue Jan 31, 2018 · 1 comment

Comments

@Jaked222
Copy link

Jaked222 commented Jan 31, 2018

Hello Savjee,

Correct me if I'm wrong, but in the third version of this code, shouldn't we add the latest block's hash when creating a new block in minePendingTransactions. Doesn't this ensure the integrity of our chain, were someone to try and alter a block?

for example:

  minePendingTransactions(miningRewardAddress) {
	let block = new Block(Date.now(), this.pendingTransactions, this.getLatestBlock().hash);
	block.mineBlock(this.difficulty);

	this.chain.push(block);
		
	this.pendingTransactions = [
		new Transaction(null, miningRewardAddress, this.miningReward)
	];
  }

also one small matter of cleanup, we no longer need to include this.index in the calculateHash function.

Thanks for the tutorials! They have definitely helped me to better understand what a blockchain is.

@Savjee
Copy link
Owner

Savjee commented Jan 31, 2018

You're absolutely right! What an oversight on my end!

I fixed those issue's in 9ebadad and 552d7ce

Thanks a lot!

@Savjee Savjee closed this as completed Jan 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants