Skip to content

Commit

Permalink
Fixed forged block indices.
Browse files Browse the repository at this point in the history
  • Loading branch information
Petteri Nevavuori committed Apr 11, 2018
1 parent bdf2135 commit 080c0b7
Showing 1 changed file with 44 additions and 50 deletions.
94 changes: 44 additions & 50 deletions blockchain/Building a General Purpose Blockchain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,6 @@
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
" * Running on http://localhost:5000/ (Press CTRL+C to quit)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
Expand All @@ -280,7 +273,8 @@
"name": "stderr",
"output_type": "stream",
"text": [
"127.0.0.1 - - [11/Apr/2018 10:00:41] \"POST /blocks HTTP/1.1\" 200 -\n"
" * Running on http://localhost:5000/ (Press CTRL+C to quit)\n",
"127.0.0.1 - - [11/Apr/2018 10:10:42] \"POST /blocks HTTP/1.1\" 200 -\n"
]
},
{
Expand All @@ -290,9 +284,9 @@
"{\n",
" \"block\": {\n",
" \"index\": 1,\n",
" \"previous_hash\": \"f198e29bb5e45e308d25579fc8f52a36fea66ba22ca61d18e654125c04116340\",\n",
" \"previous_hash\": \"9ea61d2712075fc3d3f9cf68353339caf4782f80850f8476322d8b9890d6606e\",\n",
" \"proof\": 533,\n",
" \"timestamp\": \"2018-04-11 10:00:41.379830\"\n",
" \"timestamp\": \"2018-04-11 10:10:42.723852\"\n",
" },\n",
" \"message\": \"Congratulations, you just mined a Block!\"\n",
"}\n"
Expand All @@ -302,7 +296,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"127.0.0.1 - - [11/Apr/2018 10:00:42] \"GET /blocks HTTP/1.1\" 200 -\n"
"127.0.0.1 - - [11/Apr/2018 10:10:43] \"GET /blocks HTTP/1.1\" 200 -\n"
]
},
{
Expand All @@ -315,13 +309,13 @@
" \"index\": 0,\n",
" \"previous_hash\": \"0\",\n",
" \"proof\": 1,\n",
" \"timestamp\": \"2018-04-11 10:00:40.317214\"\n",
" \"timestamp\": \"2018-04-11 10:10:41.676864\"\n",
" },\n",
" {\n",
" \"index\": 1,\n",
" \"previous_hash\": \"f198e29bb5e45e308d25579fc8f52a36fea66ba22ca61d18e654125c04116340\",\n",
" \"previous_hash\": \"9ea61d2712075fc3d3f9cf68353339caf4782f80850f8476322d8b9890d6606e\",\n",
" \"proof\": 533,\n",
" \"timestamp\": \"2018-04-11 10:00:41.379830\"\n",
" \"timestamp\": \"2018-04-11 10:10:42.723852\"\n",
" }\n",
" ],\n",
" \"length\": 2,\n",
Expand All @@ -333,7 +327,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"127.0.0.1 - - [11/Apr/2018 10:00:43] \"GET /shutdown HTTP/1.1\" 200 -\n"
"127.0.0.1 - - [11/Apr/2018 10:10:44] \"GET /shutdown HTTP/1.1\" 200 -\n"
]
}
],
Expand Down Expand Up @@ -375,7 +369,7 @@
"output_type": "stream",
"text": [
" * Running on http://localhost:5000/ (Press CTRL+C to quit)\n",
"127.0.0.1 - - [11/Apr/2018 10:00:44] \"POST /blocks HTTP/1.1\" 200 -\n"
"127.0.0.1 - - [11/Apr/2018 10:10:46] \"POST /blocks HTTP/1.1\" 200 -\n"
]
},
{
Expand All @@ -389,7 +383,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"127.0.0.1 - - [11/Apr/2018 10:00:45] \"POST /blocks HTTP/1.1\" 200 -\n"
"127.0.0.1 - - [11/Apr/2018 10:10:47] \"POST /blocks HTTP/1.1\" 200 -\n"
]
},
{
Expand All @@ -403,7 +397,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"127.0.0.1 - - [11/Apr/2018 10:00:46] \"POST /blocks HTTP/1.1\" 200 -\n"
"127.0.0.1 - - [11/Apr/2018 10:10:48] \"POST /blocks HTTP/1.1\" 200 -\n"
]
},
{
Expand All @@ -417,7 +411,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"127.0.0.1 - - [11/Apr/2018 10:00:48] \"POST /blocks HTTP/1.1\" 200 -\n"
"127.0.0.1 - - [11/Apr/2018 10:10:49] \"POST /blocks HTTP/1.1\" 200 -\n"
]
},
{
Expand All @@ -431,7 +425,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"127.0.0.1 - - [11/Apr/2018 10:00:49] \"GET /blocks HTTP/1.1\" 200 -\n"
"127.0.0.1 - - [11/Apr/2018 10:10:50] \"GET /blocks HTTP/1.1\" 200 -\n"
]
},
{
Expand All @@ -444,37 +438,37 @@
" \"index\": 0,\n",
" \"previous_hash\": \"0\",\n",
" \"proof\": 1,\n",
" \"timestamp\": \"2018-04-11 10:00:40.317214\"\n",
" \"timestamp\": \"2018-04-11 10:10:41.676864\"\n",
" },\n",
" {\n",
" \"index\": 1,\n",
" \"previous_hash\": \"f198e29bb5e45e308d25579fc8f52a36fea66ba22ca61d18e654125c04116340\",\n",
" \"previous_hash\": \"9ea61d2712075fc3d3f9cf68353339caf4782f80850f8476322d8b9890d6606e\",\n",
" \"proof\": 533,\n",
" \"timestamp\": \"2018-04-11 10:00:41.379830\"\n",
" \"timestamp\": \"2018-04-11 10:10:42.723852\"\n",
" },\n",
" {\n",
" \"index\": 2,\n",
" \"previous_hash\": \"8e0369ebcfe420065d5b3394c2ece9b06185757005b305a2d3e7277055281860\",\n",
" \"previous_hash\": \"d0ad2fc530b3da23b651b4698bd13ed7ce344a1d4eb7c8a15703f41405e403df\",\n",
" \"proof\": 45293,\n",
" \"timestamp\": \"2018-04-11 10:00:44.678168\"\n",
" \"timestamp\": \"2018-04-11 10:10:46.087295\"\n",
" },\n",
" {\n",
" \"index\": 3,\n",
" \"previous_hash\": \"df340007864a5fbd2a2465a9d2ac25f183416b5564a61fda2e87eb44d1ca18fb\",\n",
" \"previous_hash\": \"edac1c96c8bdfcc8a25fecb23fb351e28190e8d407cb774091b0838eacd2685a\",\n",
" \"proof\": 21391,\n",
" \"timestamp\": \"2018-04-11 10:00:45.831691\"\n",
" \"timestamp\": \"2018-04-11 10:10:47.198487\"\n",
" },\n",
" {\n",
" \"index\": 4,\n",
" \"previous_hash\": \"04f6299127b6fb0fb659e5b0ad54b3e2fa5d43739ae13e72a31da9ec04c7a18a\",\n",
" \"previous_hash\": \"4f7812e3d8af187f80b8fb71c995d1e5bec82a7e228280d5c7c3e796b7e76207\",\n",
" \"proof\": 8018,\n",
" \"timestamp\": \"2018-04-11 10:00:46.882162\"\n",
" \"timestamp\": \"2018-04-11 10:10:48.225742\"\n",
" },\n",
" {\n",
" \"index\": 5,\n",
" \"previous_hash\": \"003a0b87af5ad8d94070f7632b12b90ff18c4271fd7e2eae395be7b02aeaa50b\",\n",
" \"previous_hash\": \"0d3f5fb4c69a4f869fee173f096c2f6157ac8dcebbc31dc0468bf9c382480e9e\",\n",
" \"proof\": 48191,\n",
" \"timestamp\": \"2018-04-11 10:00:48.076540\"\n",
" \"timestamp\": \"2018-04-11 10:10:49.359195\"\n",
" }\n",
" ],\n",
" \"length\": 6,\n",
Expand All @@ -486,7 +480,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"127.0.0.1 - - [11/Apr/2018 10:00:50] \"GET /shutdown HTTP/1.1\" 200 -\n"
"127.0.0.1 - - [11/Apr/2018 10:10:51] \"GET /shutdown HTTP/1.1\" 200 -\n"
]
}
],
Expand Down Expand Up @@ -534,14 +528,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Proofs: Original=21391, Forged=21391\n"
"Proofs: Original=533, Forged=12345\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"127.0.0.1 - - [11/Apr/2018 10:00:51] \"GET /blocks HTTP/1.1\" 500 -\n"
"127.0.0.1 - - [11/Apr/2018 10:10:52] \"GET /blocks HTTP/1.1\" 500 -\n"
]
},
{
Expand All @@ -554,37 +548,37 @@
" \"index\": 0,\n",
" \"previous_hash\": \"0\",\n",
" \"proof\": 1,\n",
" \"timestamp\": \"2018-04-11 10:00:40.317214\"\n",
" \"timestamp\": \"2018-04-11 10:10:41.676864\"\n",
" },\n",
" {\n",
" \"index\": 1,\n",
" \"previous_hash\": \"f198e29bb5e45e308d25579fc8f52a36fea66ba22ca61d18e654125c04116340\",\n",
" \"previous_hash\": \"9ea61d2712075fc3d3f9cf68353339caf4782f80850f8476322d8b9890d6606e\",\n",
" \"proof\": 12345,\n",
" \"timestamp\": \"2018-04-11 10:00:41.379830\"\n",
" \"timestamp\": \"2018-04-11 10:10:42.723852\"\n",
" },\n",
" {\n",
" \"index\": 2,\n",
" \"previous_hash\": \"8e0369ebcfe420065d5b3394c2ece9b06185757005b305a2d3e7277055281860\",\n",
" \"previous_hash\": \"d0ad2fc530b3da23b651b4698bd13ed7ce344a1d4eb7c8a15703f41405e403df\",\n",
" \"proof\": 45293,\n",
" \"timestamp\": \"2018-04-11 10:00:44.678168\"\n",
" \"timestamp\": \"2018-04-11 10:10:46.087295\"\n",
" },\n",
" {\n",
" \"index\": 3,\n",
" \"previous_hash\": \"df340007864a5fbd2a2465a9d2ac25f183416b5564a61fda2e87eb44d1ca18fb\",\n",
" \"previous_hash\": \"edac1c96c8bdfcc8a25fecb23fb351e28190e8d407cb774091b0838eacd2685a\",\n",
" \"proof\": 21391,\n",
" \"timestamp\": \"2018-04-11 10:00:45.831691\"\n",
" \"timestamp\": \"2018-04-11 10:10:47.198487\"\n",
" },\n",
" {\n",
" \"index\": 4,\n",
" \"previous_hash\": \"04f6299127b6fb0fb659e5b0ad54b3e2fa5d43739ae13e72a31da9ec04c7a18a\",\n",
" \"previous_hash\": \"4f7812e3d8af187f80b8fb71c995d1e5bec82a7e228280d5c7c3e796b7e76207\",\n",
" \"proof\": 8018,\n",
" \"timestamp\": \"2018-04-11 10:00:46.882162\"\n",
" \"timestamp\": \"2018-04-11 10:10:48.225742\"\n",
" },\n",
" {\n",
" \"index\": 5,\n",
" \"previous_hash\": \"003a0b87af5ad8d94070f7632b12b90ff18c4271fd7e2eae395be7b02aeaa50b\",\n",
" \"previous_hash\": \"0d3f5fb4c69a4f869fee173f096c2f6157ac8dcebbc31dc0468bf9c382480e9e\",\n",
" \"proof\": 48191,\n",
" \"timestamp\": \"2018-04-11 10:00:48.076540\"\n",
" \"timestamp\": \"2018-04-11 10:10:49.359195\"\n",
" }\n",
" ],\n",
" \"length\": 6,\n",
Expand All @@ -596,14 +590,14 @@
"name": "stderr",
"output_type": "stream",
"text": [
"127.0.0.1 - - [11/Apr/2018 10:00:52] \"GET /shutdown HTTP/1.1\" 200 -\n"
"127.0.0.1 - - [11/Apr/2018 10:10:53] \"GET /shutdown HTTP/1.1\" 200 -\n"
]
}
],
"source": [
"original = blockchain.chain[3]['proof']\n",
"original = blockchain.chain[1]['proof']\n",
"blockchain.chain[1]['proof'] = 12345\n",
"print('Proofs: Original={}, Forged={}'.format(original,blockchain.chain[3]['proof']))\n",
"print('Proofs: Original={}, Forged={}'.format(original,blockchain.chain[1]['proof']))\n",
"\n",
"with BlockchainApp() as blockchain_app:\n",
" \n",
Expand All @@ -620,15 +614,15 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hashes: \n",
"\tOriginal =\t8e0369ebcfe420065d5b3394c2ece9b06185757005b305a2d3e7277055281860\n",
"\tOriginal =\td0ad2fc530b3da23b651b4698bd13ed7ce344a1d4eb7c8a15703f41405e403df\n",
"\tForged =\tb3e1a78ae4b5cd947a6690f4a5ee9b3a71a13a2df00d77cbc4c904c9b2ac2deb\n"
]
}
Expand Down

0 comments on commit 080c0b7

Please sign in to comment.