示例#1
0
from blockchain.chain import Block, Blockchain

# ==================================================
# ===== SUPPORTED COMMANDS LIST IN BLOCKSHELL ======
# ==================================================
SUPPORTED_COMMANDS = [
    'sendtx',
    'mineblock',
    'allblocks',
    'mempool',
    'getblock',
    'help'
]

# Init blockchain
coin = Blockchain()

# Create group of commands
@click.group()
def cli():
    """
        Create a group of commands for CLI
    """
    pass

# ==================================================
# ============= BLOCKSHELL CLI COMMAND =============
# ==================================================
@cli.command()
@click.option("--difficulty", default=3, help="Define difficulty level of blockchain.")
def init(difficulty):
示例#2
0
import config
from blockchain.chain import Blockchain
import ZODB, ZODB.FileStorage
import transaction

# Setup db and make module globals available
storage = ZODB.FileStorage.FileStorage(config.DB_PATH)
db = ZODB.DB(storage)
connection = db.open()
if not hasattr(connection.root, "blockchain"):
    connection.root.blockchain = Blockchain()
    transaction.commit()

chain = connection.root.blockchain