Splitting The Blockchain
After just a week the blockchain.json file had grown to around 100mb so it was clear we needed to do something before this started causing problems with taking up too much RAM and causing delays writing to disk. While it might have been workable to let it grow for some time, a solution was proposed to verify the ledger then create a summary on a new blockchain file and start the blockchain writing again.
So at 10,000 blocks the blockchain was split. Successfully, first time without any bugs or problems. Phew! It was nail biting in the countdown as even though we’d tested the code and checked it over and over again you never really know for sure it’ll work until it does.
So blockchain1.json has been written to history. The first 10,000 JSE blocks. This file will not and cannot be changed. The previous hash is carried over to the new file along with the data balance ledger. So the first block of blockchain2.json contains a new command “summary” which lists the balances of each user. This allowed us to verify the new blockchain file against the ledger straight away without any system disruption.
The blockchain will now split off every 10,000 blocks with all previous transactions being written to history and a ledger being moved forwards. The previous blocks are publically available and will be needed for some technical users. For 99% of developers and stakeholders though the smaller blockchain and ledger system will mean faster sync times and improved performance.
As transactions increase the disk size of 10,000 blocks will increase. Even with this taken in to account the file should stay well below 1GB which is quite manageable on the current hardware infrastructure.