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.
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.
Performing a JSON.stringify on an object will not always give the same value as objects are unordered.