Something is wrong receiving the database from peers.
Hey mate! I love the simplicity of this code it's nice.
I added mysql / dev mode genesis block from a json file.
I have one issue tho. I don't know why but when I write a block to the main peers (more advanced one let's say 10 blocks), the seconds peer (from genesis so 1 block) actually tell that the main peer is more advanced but it's not updating the blockchain.
As I said I added mysql so maybe is the format encoding of the blockchain? I tried with the original it worked but weirdly, only sometimes and partially. I also changed "data" block field to "from" and "to"
I also spotted here :
public function replaceChain($newBlocks) { if (self::isValidChain($newBlocks) && count($newBlocks) > count($blockchain)) { echo ('Received blockchain is valid. Replacing current blockchain with received blockchain'); $blockchain = $newBlocks; $this->network->broadcast(['query' => 'addBlock', 'data' => [ $this->network->getLatestBlock() ] ]); } else { echo ('Received blockchain invalid'); } }
The $blockchain value is never used!