The source code of originally based on post on Building a Blockchain of Daniel van Flymen.
-
Make sure Python 2.7x is installed.
-
Install requirements (preferably inside a virtual environment).
$ pip install -r requirements.txt
- Run the server:
$ python blockchain.py -p 5001 -db pow.db -v pow
'-p', '--port', default=5000, type=int, help='port to listen on'
'-db', '--database', default='', help='db file, if not passed, then no persistance'
'-v', '--variant', default='pow', help='variant of blockchain "pow" or "pos"'
'-s', '--socket', default=6001, type=int, help='p2p port to listen on'
'-d', '--difficulty', default=2, help='initial difficulty'
'-k', '--keystore', default='/tmp/private_key.pem', help='where the keystore is located.'
To install mininet please follow http://mininet.org/vm-setup-notes/, a fresh mininet virtual environment setup is recommended. For the VM Mininet 2.2.2 on Ubuntu 14.04 LTS - 64 bit follow these steps:
Clone the project into a directory. cd
to cloned directory.
sudo python setup.py install
sudo easy_install dist/bal-xxx.egg
sudo ln -s /home/mininet/bal/bal/blockchain.py /usr/local/bin/blockchain.py
change #!/bin/env python
in blockchain.py
to #!usr/bin/env python
.
Mininet's custom setup for BAL classes balmn.py add several types of hosts:
- pow -- bcnode.POWNode
- pos -- bcnode.POSNode
For example:
mn --custom=balmn.py --host=pos
Simulating (under bal/bal directory):
./bcmn_test.py
you may find in the project's Wiki.