CryptBank is a storage system that serves as a database for distributed blockchain applications, including cryptocurrencies. Its main component is the chain which involves a coin database, chain writer, and a block info database.
- Latest version of
Google Protobuf
installed - Latest version of
GoogleTest
installed - Latest version of
CMake
installed (on MacOS, you can install via Homebrew withbrew install cmake
)
rm -rf build && mkdir build && cd build
cmake ..
make
cd ..
cd build
make test
The coin database is a database that stores all the Coin
objects, manages the storage between RAM and disk by using a cache, and keeps track of which TXOs are spent. A Coin
is an object that contains Transaction Outputs (TXOs) and whether it is spent or not.
The chain writer is an interface that is used to perform read-write disk opertions on the blocks and undo blocks of the chain. When a block is written to disk, the chain writer is responsible for writing the block to the disk and the undo block to the disk. A BlockRecord
will be used to track where the block and undo block are stored. This is constructed by passing in two FileInfo
objects that represents the location of the block and undo block.
The whole idea of the chain writer revolves around how blocks are rarely accessed by users but take up a lot of space. So, rather than storing it in RAM, It is stored on disk.
The block info database is a database that stores all the BlockRecord
objects mentioned above. It is used to keep track of where the blocks and undo blocks are stored, the current height of the chain, and the essential information regarding the block which is stored in the BlockHeader
object.