dvf / blockchain

A simple Blockchain in Python
MIT License
7.81k stars 2.75k forks source link

How to operate with the blockchain if it grows very large? #151

Closed fgRuslan closed 5 years ago

fgRuslan commented 5 years ago

@dvf Hello. I have written a function that saves the blockchain to a JSON file and when the script is run, it is loaded from this JSON file. What if the blockchain grows really large? While the blockchain.py is working, the blockchain is stored in RAM. What if it grows to more gigabytes than my computer has got? I can provide my code if you need it.

dvf commented 5 years ago

This is a problem with all Blockchains... the Bitcoin blockchain is around 250+ GB. You can either look at compression or discard blocks older than a certain amount.

fgRuslan commented 5 years ago

I don't know how does Bitcoin blockchain exactly work, but I don't think it tries to load a single 250+ GB file into RAM. Or does it?

dvf commented 5 years ago

Not into RAM, but into its file-based Level DB: https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage