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 call to executeTransactions() #2

Open
AndrejMitrovic opened this issue May 14, 2019 · 3 comments
Open

Missing call to executeTransactions() #2

AndrejMitrovic opened this issue May 14, 2019 · 3 comments

Comments

@AndrejMitrovic
Copy link

console.log("NEW BLOCK ADDED");

Before this function returns, it should call this.executeTransactions(block);. This way the accounts are updated.

Btw, you wrote an excellent tutorial! It's really appreciated.

Cheers!

@kashishkhullar
Copy link
Owner

Thanks man, I had to complete it in a hurry, therefore there are lot of bugs. And I have been busy lately so i couldn't fix this stuff.

@kashishkhullar
Copy link
Owner

Create a PR and I'll merge it.

kashishkhullar added a commit that referenced this issue May 10, 2020
fix : executeTransactions() issue #2
@ryan-rozario
Copy link

I think this part of the code needs to be changed.

addBlock(data) {
let block = Block.createBlock(
this.chain[this.chain.length - 1],
data,
new Wallet(secret)
);

The part of the code shown below that calls this function actually passes a block object to the function.

isValidBlock(block) {
const lastBlock = this.chain[this.chain.length - 1];
if (
block.lastHash === lastBlock.hash &&
block.hash === Block.blockHash(block) &&
Block.verifyBlock(block) &&
Block.verifyLeader(block, this.getLeader())
) {
console.log("block valid");
this.addBlock(block);

The block object was already created when the message was sent from the other node and there is no need to create a block again as you have done. You just have to add it to the chain as it was in the original code.

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

3 participants