Skip to content

blockchain invalid error when syncing a longer blockchain #29

Description

@koshikraj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions