Milestone:blockchain download/verify/store working

- Major refactor of KDB, added write-ahead mechanism so that an
interrupted file write can be restored.
- and other changes related to blockchain catchup downloading.