THIS REPOSITORY CLOSED! ALL DEVELOPMENT MOVED TO https://balchemylab.gitlab.io
The source code of originally based on post on Building a Blockchain of Daniel van Flymen.
-
Make sure Python 2 or 3 is installed.
-
Install requirements (preferably inside a virtual environment).
$ pip install -r requirements.txt
- Run the server:
$ python2 blockchain.py -p 5001 -d pow.db -v pow:2
$ python3 blockchain.py --port 5002 --db quant.db --variant quant
'-p', '--port', default=5000, type=int, help='port to listen on'
'-d', '--db', default='', help='db file, if not passed, then no persistance'
'-v', '--variant', default='pow', help='variant of blockchain "pow[:difficulty]" or "quant", where:
* pow[:difficulty] -- POWBlockChain with possibility of "difficulty" setting (4 by default)
* quant -- QuantumBlockChain
For QuantumBlockChain, the keyworker service must be started.
Internal test:
python -m unittest tests.test_BaseBlockChain
Test REST API POW:
- Run blockchain.py servers on ports 5000 and 5001 with POW variant.
- Run test script:
./tests/test.sh
Test REST API QUANTUM:
- Run blockchain.py servers on ports 5000 and 5001 with quantum variants.
- Run keyworker on port 55554
- Run test script:
./tests/testquantum.sh
Mininet's custom setup for BAL classes balmn.py add several types of hosts:
- btc -- bcnode.BtcNode
- eth -- bcnode.EthNode
- pow -- bcnode.POWNode
- qkd -- bcnode.QNode
For example:
mn --custom=balmn.py --host=btc
Testing:
./bcmn_test.py [host_type]
Test with quantum links:
mn --custom=bal/QKCustom.py --link=qk --topo=tree,depth=2,fanout=3
Test with ryu:
sudo mn --custom bal/topo_2sw-2host.py --topo mytopo --mac --controller remote --switch ovs
Go to 'bal' directory and start ryu-manager:
cd bal
sudo ryu-manager rest_forward.py
You can switch channels with RestAPI: For raw channel:
curl -X GET http://localhost:8080/channel/1/1
For quantum channel:
curl -X GET http://localhost:8080/channel/1/2
you may find in the project's Wiki.