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

blockchain invalid error when syncing a longer blockchain #29

Open
koshikraj opened this issue Mar 7, 2018 · 4 comments
Open

blockchain invalid error when syncing a longer blockchain #29

koshikraj opened this issue Mar 7, 2018 · 4 comments

Comments

@koshikraj
Copy link

Created 2 nodes,
node1 has 41 blocks created using mineBlock API
node2 has only genesis block
when node 2 is connected to peer node1, it gives following error and fails to replace the blockchain

blockchain possibly behind. We got: 0 Peer got: 41
Received blockchain is longer than current blockchain
Received blockchain invalid

The error is likely to be because of the first condition in isValidChain when called from replacechain.


var isValidChain = (blockchainToValidate) => {
    if (JSON.stringify(blockchainToValidate[0]) !== JSON.stringify(getGenesisBlock())) {
        return false;

Performing a JSON.stringify on an object will not always give the same value as objects are unordered.

@koshikraj
Copy link
Author

Can someone verify this issue?

@gentleKun
Copy link

I have no such issue.

@koshikraj
Copy link
Author

@gentleKun , This issue is due to stringifying the unordered dictionary. May not be reproducible every time. It is always safer to compare the hash value instead which proves the integrity.

@gentleKun
Copy link

I know the question where it is , and i have modified it in my file main.js file.

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