Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 1.59 KB

README.md

File metadata and controls

18 lines (13 loc) · 1.59 KB

Coin

Introduction

Coin is an example storage system (a blockchain) for a cryptocurrency. Coin is modeled after Bitcoin's storage system, though heavily simplified. The goal of this project is to have a taste of the many working components of a blockchain.

Components

Coin consists of several main components. Here's a quick overview:

  1. BlockChain
    • The main type of this project, BlockChain is a blockchain that stores and validates Blocks. It manages and updates its main chain based on the Blocks it receives. Watch out for forks!
  2. BlockInfoDatabase
    • The BlockInfoDatabase is a wrapper for a LevelDB, storing information about each Block it receives in the form of a BlockRecord. In addition, each BlockRecord contains storage information for an UndoBlock, which provides additional information to revert a Block, should a fork occur.
  3. ChainWriter
    • The ChainWriter takes care of all I/O for the BlockChain. It writes and reads Blocks and UndoBlocks to Disk.
  4. CoinDatabase
    • CoinDatabase stores all UTXO information. It contains a cache of Coins and a LevelDB of CoinRecords. A Coin is a wrapper for a UTXO, and a CoinRecord is a record of all the UTXO created by a Transaction. Validation needs to be as quick as possible, which is why the CoinDatabase contains an in-memory cache in addition to a persistent database. Eventually the cache becomes too large, at which point the CoinDatabase must flush its cache to its database.