bitshares / bitshares1-core

Software to run the old chain (before 2015-10-13). Code for current chain is https://github.com/bitshares/bitshares-core
https://bitshares.org/
The Unlicense
219 stars 174 forks source link

Allow to truncate blockchain #1157

Open theoreticalbts opened 9 years ago

theoreticalbts commented 9 years ago

There should be an option to throw away blocks above a certain height (and probably need to throw away indexes as well). The idea is to make resolving a fork not require a full re-download of the blockchain.

nathanielhourt commented 9 years ago

The better solution here would be to simply expose a command to switch to fork containing a given block ID. There's no need to throw data away (that can be done later). Better to keep everything to allow us to switch back if need be.

Implementing this command should be trivial. Just call switch_to_fork()

theoreticalbts commented 9 years ago

Wouldn't you have to re-process from the beginning to update the chain state? I'm pretty sure there's some max undo length; in other words we don't keep the data to rewind the state arbitrarily far in the past.

nathanielhourt commented 9 years ago

If you need to rewind more than max undo history, yes, you'll need to completely reindex.