From 7b2b23730e14fc0afe6c3687ec2de5317a482665 Mon Sep 17 00:00:00 2001 From: Mohit-Arya1211 Date: Sun, 6 Oct 2019 02:32:58 +0530 Subject: [PATCH] Updated blockchain.py server IP and minor fixes --- blockchain.py | 4 ++-- js/blockchain.js | 3 +++ requirements.txt | 4 ++-- tests/test_blockchain.py | 12 ++++++------ 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/blockchain.py b/blockchain.py index 937d3521..857c01a3 100644 --- a/blockchain.py +++ b/blockchain.py @@ -14,7 +14,7 @@ def __init__(self): self.chain = [] self.nodes = set() - # Create the genesis block + # Create the genesis block(1st Block) self.new_block(previous_hash='1', proof=100) def register_node(self, address): @@ -37,7 +37,7 @@ def register_node(self, address): def valid_chain(self, chain): """ Determine if a given blockchain is valid - + :param chain: A blockchain :return: True if valid, False if not """ diff --git a/js/blockchain.js b/js/blockchain.js index 9457b3cd..e82bc06e 100644 --- a/js/blockchain.js +++ b/js/blockchain.js @@ -1,3 +1,4 @@ + const crypto = require("crypto"); @@ -80,6 +81,8 @@ class Blockchain { /** * Proof of Work mining algorithm + with RPoW and Mining Efficiency + * * We hash the block with random string until the hash begins with * a "difficulty" number of 0s. diff --git a/requirements.txt b/requirements.txt index 990b2d8a..3a1bf85a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -flask==0.12.2 -requests==2.18.4 +flask>=0.12.2 +requests>=2.18.4 diff --git a/tests/test_blockchain.py b/tests/test_blockchain.py index f2d85e10..362e3222 100644 --- a/tests/test_blockchain.py +++ b/tests/test_blockchain.py @@ -26,22 +26,22 @@ class TestRegisterNodes(BlockchainTestCase): def test_valid_nodes(self): blockchain = Blockchain() - blockchain.register_node('http://192.168.0.1:5000') + blockchain.register_node('http://192.168.0.1:4444') - self.assertIn('192.168.0.1:5000', blockchain.nodes) + self.assertIn('192.168.0.1:4444', blockchain.nodes) def test_malformed_nodes(self): blockchain = Blockchain() - blockchain.register_node('http//192.168.0.1:5000') + blockchain.register_node('http//192.168.0.1:4444') - self.assertNotIn('192.168.0.1:5000', blockchain.nodes) + self.assertNotIn('192.168.0.1:4444', blockchain.nodes) def test_idempotency(self): blockchain = Blockchain() - blockchain.register_node('http://192.168.0.1:5000') - blockchain.register_node('http://192.168.0.1:5000') + blockchain.register_node('http://192.168.0.1:4444') + blockchain.register_node('http://192.168.0.1:4444') assert len(blockchain.nodes) == 1