blockshell not found buf fixed

This commit is contained in:
Daxeel Soni 2018-01-27 19:19:35 +05:30
commit b79d1af2d3
5 changed files with 163 additions and 12 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ venv/
build/
dist/
blockshell/
blockshell.egg-info/

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Daxeel Soni
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,2 +1,71 @@
# blockshell
A command line utility for learning Blockchain.
# BlockShell
A command line utility for learning Blockchain technical concepts likechaining, mining, proof of work etc.
<img src="https://image.ibb.co/mJFNGw/blockshell.gif">
<img src="https://preview.ibb.co/dhC7yb/Logomakr_5g_Ei_Dw.png" height="80">
## About
Anyone who wants to understand how blockchain technology works, then <b>BlockShell</b> should be a great start. Because I have created BlockShell keeping blockchain fundamentals in the center of development. With BlockShell you will actually create a tiny blockchain in your system where you can create blocks with data, explore blocks etc.
So, by using BlockShell anyone can learn following blockchain concepts,
* Block & Chaining
* Hashing
* Mining
* Proof of Work
## BlockShell Web Explorer
<p>BlockShell comes with built-in blockchain explorer by which you can actully see how blocks are mined and what is stored and where.</p>
Latest Mined Blocks | Block Details
:------------------------------:|:-------------------------:
![](https://preview.ibb.co/iZa5jG/Screen_Shot_2018_01_25_at_11_25_22_PM.png) | ![](https://preview.ibb.co/cDB0Jb/Screen_Shot_2018_01_25_at_11_25_35_PM.png)
## Installation
Step 1 - Create project directory
```
mkdir <project_name> && cd project_name
```
Step 2 - Create new virtual environment
```
virtualenv venv
```
Step 3 - Activate virtual environment
```
source venv/bin/activate
```
Step 4 - Clone this repo
```
git clone https://github.com/daxeel/blockshell.git
```
Step 5 - Change directory to cloned one
```
cd blockshell
```
Step 6 - Install blockshell
```
python setup.py install
```
Step 7 - Try "blockshell" command and test installation!
```
blockshell
```
<b>Output in terminal after calling BlockShell command</b>
<img src="https://image.ibb.co/dRqGrw/Screen_Shot_2018_01_25_at_11_21_38_PM.png">
## Lanuch BlockShell Web
Step 1 - Start new terminal window, go to cloned directory
Step 2 - Start web.py
```
python web.py
```
Step 3 - Go to 127.0.0.1:5000 address in browser and boom!

View File

@ -1,11 +1,25 @@
# -*- coding: utf-8 -*-
# import modules
# ==================================================
# ==================== META DATA ===================
# ==================================================
__author__ = "Daxeel Soni"
__url__ = "https://daxeel.github.io"
__email__ = "daxeelsoni44@gmail.com"
__license__ = "MIT"
__version__ = "0.1"
__maintainer__ = "Daxeel Soni"
# ==================================================
# ================= IMPORT MODULES =================
# ==================================================
import click
import urllib
import json
from blockchain.chain import Block, Blockchain
# Supported commands
# ==================================================
# ===== SUPPORTED COMMANDS LIST IN BLOCKSHELL ======
# ==================================================
SUPPORTED_COMMANDS = [
'dotx',
'allblocks',
@ -19,9 +33,14 @@ coin = Blockchain()
# Create group of commands
@click.group()
def cli():
"""
Create a group of commands for CLI
"""
pass
# Start lbc cli
# ==================================================
# ============= BLOCKSHELL CLI COMMAND =============
# ==================================================
@cli.command()
@click.option("--difficulty", default=3, help="Difine dufficulty level of blockchain.")
def init(difficulty):
@ -36,19 +55,23 @@ def init(difficulty):
> A command line utility for learning Blockchain concepts.
> Type 'help' to see supported commands.
> Project by Daxeel Soni - https://daxeel.github.io
"""
# Set difficulty of blockchain
coin.difficulty = difficulty
# Start lbc chell
# Start blockshell shell
while True:
cmd = raw_input("[BlockShell] $ ")
processInput(cmd)
# Process input from LBC shell
# Process input from Blockshell shell
def processInput(cmd):
"""
Method to process user input from Blockshell CLI.
"""
userCmd = cmd.split(" ")[0]
if len(cmd) > 0:
if userCmd in SUPPORTED_COMMANDS:
@ -58,10 +81,14 @@ def processInput(cmd):
msg = "Command not found. Try help command for documentation"
throwError(msg)
# ------------------------------------
# Supported Commands Methods
# ------------------------------------
# ==================================================
# =========== BLOCKSHELL COMMAND METHODS ===========
# ==================================================
def dotx(cmd):
"""
Do Transaction - Method to perform new transaction on blockchain.
"""
txData = cmd.split("dotx ")[-1]
if "{" in txData:
txData = json.loads(txData)
@ -69,12 +96,18 @@ def dotx(cmd):
coin.addBlock(Block(data=txData))
def allblocks(cmd):
"""
Method to list all mined blocks.
"""
print ""
for eachBlock in coin.chain:
print eachBlock.hash
print ""
def getblock(cmd):
"""
Method to fetch the details of block for given hash.
"""
blockHash = cmd.split(" ")[-1]
for eachBlock in coin.chain:
if eachBlock.hash == blockHash:
@ -83,10 +116,16 @@ def getblock(cmd):
print ""
def help(cmd):
"""
Method to display supported commands in Blockshell
"""
print "Commands:"
print " dotx <transaction data> Create new transaction"
print " allblocks Fetch all mined blocks in blockchain"
print " getblock <block hash> Fetch information about particular block"
def throwError(msg):
"""
Method to throw an error from Blockshell.
"""
print "Error : " + msg

25
web.py
View File

@ -1,10 +1,28 @@
# -*- coding: utf-8 -*-
# ==================================================
# ==================== META DATA ===================
# ==================================================
__author__ = "Daxeel Soni"
__url__ = "https://daxeel.github.io"
__email__ = "daxeelsoni44@gmail.com"
__license__ = "MIT"
__version__ = "0.1"
__maintainer__ = "Daxeel Soni"
# ==================================================
# ================= IMPORT MODULES =================
# ==================================================
from flask import Flask, render_template, jsonify
import json
# Init flask app
app = Flask(__name__)
@app.route('/')
def blocks():
def mined_blocks():
"""
Endpoint to list all mined blocks.
"""
f = open("chain.txt", "r")
data = json.loads(f.read())
f.close()
@ -12,6 +30,9 @@ def blocks():
@app.route('/block/<hash>')
def block(hash):
"""
Endpoint which shows all the data for given block hash.
"""
f = open("chain.txt", "r")
data = json.loads(f.read())
f.close()
@ -19,6 +40,6 @@ def block(hash):
if eachBlock['hash'] == hash:
return render_template('blockdata.html', data=eachBlock)
# Run flask app
if __name__ == '__main__':
app.run(debug=True)