项目作者: DEMG-DEV

项目描述 :
Simple Database based on Blockchain technology.
高级语言: Python
项目地址: git://github.com/DEMG-DEV/SimpleBlockchainDataBase.git
创建时间: 2018-09-24T21:38:34Z
项目社区:https://github.com/DEMG-DEV/SimpleBlockchainDataBase

开源协议:MIT License

下载


SimpleBlockchainDatabase Open Source Helpers

In this repository you can found a simple Database based on blockchain technology.

IN THIS MOMENT THE DATABASE JUST WORK AS LOCALLY AND ONE DEVICE

Version

1.1.4

LICENSE

MIT License

Requirements

Python >= 3.6

Project structure

  1. ├── BlockchainDataBase
  2. ├── Data
  3. ├── __init__.py
  4. ├── DBManage.py
  5. ├── __init__.py
  6. ├── Block.py
  7. ├── Blockchain.py
  8. ├── Test
  9. ├── Test1.py
  10. ├── Test2.py
  11. ├── Test3.py
  12. ├── Test4.py
  13. ├── LICENSE
  14. ├── README.md
  15. ├── setup.py

Test

  • Test1.py, This test just creates the genesis block of the blockchain.
  • Test2.py, This test add a one block to the blockchain and prints the blocks.
  • Test3.py, This test add 2 blocks into the blockchain, prints the blocks and validate the blockchain.
  • Test4.py, This shows all the blocks.

Install

From official pypi.org

  1. python -m pip install BlockchainDataBase

From test.pypi.org

  1. python -m pip install --index-url https://test.pypi.org/simple/ BlockchainDataBase

Configuration

On the folder you found a configuration file in a JSON format, if you want to change the folder on the database or database name you do in this file.

  1. # The data saves on %APPDATA% directory.
  2. ├── blockchain
  3. ├── config.json
  1. config.json
  2. {
  3. "DEFAULT": {
  4. "DATABASE_NAME": "blockchain_database.bc",
  5. "CONFIG_FILE": "config.json"
  6. }
  7. }

Examples

Initialize the Blockchain.

  1. from BlockchainDataBase.Blockchain import Blockchain
  2. bc = Blockchain()

Add one block into Blockchain.

  1. data = {"Data": "dataResult"}
  2. bc.add_block(data)

Shows all the blocks in the Blockchain.

  1. bc.print_blocks()

Validates the blockchain to check if not was corrupted

  1. bc.validate_chain()