├── .env ├── docs ├── bcb_vosy.pdf ├── sample.png ├── architecture.png └── network_sample.png ├── docker ├── orderer │ └── Dockerfile ├── vosy │ └── Dockerfile ├── certificate_authority │ └── Dockerfile └── peer │ └── Dockerfile ├── vosy_app ├── utils.py ├── templates │ ├── base.html │ └── index.html ├── chaincode.py └── vosy.py ├── bcb_server ├── utils.py ├── block.py ├── certificate_authority.py ├── blockchain.py ├── orderer.py └── peer.py ├── docker-compose-peer-only.yml ├── requirements.txt ├── docker-compose.yml ├── .gitignore └── README.md /.env: -------------------------------------------------------------------------------- 1 | ORDERER_IP=192.168.43.162 2 | CA_IP=192.168.43.162 3 | PEER_IP=192.168.43.162 -------------------------------------------------------------------------------- /docs/bcb_vosy.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorykop/voting-blockchain/HEAD/docs/bcb_vosy.pdf -------------------------------------------------------------------------------- /docs/sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorykop/voting-blockchain/HEAD/docs/sample.png -------------------------------------------------------------------------------- /docs/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorykop/voting-blockchain/HEAD/docs/architecture.png -------------------------------------------------------------------------------- /docs/network_sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/victorykop/voting-blockchain/HEAD/docs/network_sample.png -------------------------------------------------------------------------------- /docker/orderer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7 2 | COPY . /code 3 | EXPOSE 5001 4 | 5 | WORKDIR /code 6 | 7 | RUN pip install -r requirements.txt 8 | 9 | ENTRYPOINT python bcb_server/orderer.py -------------------------------------------------------------------------------- /docker/vosy/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7 2 | COPY . /code 3 | 4 | EXPOSE 5001 5 | 6 | WORKDIR /code 7 | 8 | RUN pip install -r requirements.txt 9 | 10 | # ENV HOST_IP '0.0.0.0' 11 | 12 | ENTRYPOINT python vosy_app/vosy.py --host $HOST_IP -------------------------------------------------------------------------------- /docker/certificate_authority/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7 2 | COPY . /code 3 | EXPOSE 5001 4 | 5 | WORKDIR /code 6 | 7 | RUN pip install -r requirements.txt 8 | 9 | # ENV ORDERER_IP '0.0.0.0' 10 | 11 | ENTRYPOINT python bcb_server/certificate_authority.py --orderer $ORDERER_IP -------------------------------------------------------------------------------- /docker/peer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:2.7 2 | COPY . /code 3 | EXPOSE 5001 4 | 5 | WORKDIR /code 6 | 7 | RUN pip install -r requirements.txt 8 | 9 | # ENV ORDERER_IP '0.0.0.0' 10 | # ENV CA_IP '0.0.0.0' 11 | 12 | ENTRYPOINT python bcb_server/peer.py --ca $CA_IP --orderer $ORDERER_IP -------------------------------------------------------------------------------- /vosy_app/utils.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | def get_ip(remote_addr = '127.0.0.1'): 4 | 5 | if remote_addr != '127.0.0.1': 6 | return remote_addr 7 | 8 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 9 | try: 10 | # doesn't even have to be reachable 11 | s.connect(('10.255.255.255', 1)) 12 | IP = s.getsockname()[0] 13 | except: 14 | IP = '127.0.0.1' 15 | finally: 16 | s.close() 17 | return IP 18 | -------------------------------------------------------------------------------- /bcb_server/utils.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | def get_ip(remote_addr = '127.0.0.1'): 4 | 5 | if remote_addr != '127.0.0.1': 6 | return remote_addr 7 | 8 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 9 | try: 10 | # doesn't even have to be reachable 11 | s.connect(('10.255.255.255', 1)) 12 | IP = s.getsockname()[0] 13 | except: 14 | IP = '127.0.0.1' 15 | finally: 16 | s.close() 17 | return IP 18 | -------------------------------------------------------------------------------- /docker-compose-peer-only.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | 4 | services: 5 | peer.org1.bcbvosy.com: 6 | container_name: peer.org1.bcbvosy.com 7 | build: 8 | context: . 9 | dockerfile: ./docker/peer/Dockerfile 10 | environment: 11 | - ORDERER_IP=${ORDERER_IP} 12 | - CA_IP=${CA_IP} 13 | ports: 14 | - "5000:5000" 15 | # network_mode: "host" 16 | volumes: 17 | - .:/code 18 | 19 | vosy.org1.bcbvosy.com: 20 | container_name: vosy.org1.bcbvosy.com 21 | build: 22 | context: . 23 | dockerfile: ./docker/vosy/Dockerfile 24 | environment: 25 | - HOST_IP=peer.org1.bcbvosy.com 26 | ports: 27 | - "8080:8080" 28 | # network_mode: "host" 29 | volumes: 30 | - .:/code 31 | -------------------------------------------------------------------------------- /vosy_app/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 |To create new survey, please click Update Chaincode and Mine before
81 | {{post.question}}
99 | {% for answer, votes in post.answers.items() %} 100 | {% if post.status == 'opening' %} 101 |