blockchain

用Python实现的简单区块链。(A simple Blockchain in Python.)

Github星跟蹤圖

通过构建一个学习区块链

这是我在构建区块链上的帖子的源代码。

安装

  1. 确保安装了 Python 3.6+
  2. 安装 pipenv
$ pip install pipenv
  1. 安装要求
$ pipenv install
  1. 运行服务器:
    • $ pipenv run python blockchain.py
    • $ pipenv run python blockchain.py -p 5001
    • $ pipenv run python blockchain.py --port 5002

Docker

运行这个区块链程序的另一个选择是使用Docker。按照以下说明创建本地Docker容器:

  1. 克隆此存储库
  2. 建立docker container
$ docker build -t blockchain。
    1. 运行容器
    $ docker run --rm -p 80:5000 blockchain
    
    1. 要添加更多实例,请在冒号前改变公共端口号:
    $ docker run --rm -p 81:5000 blockchain
    $ docker run --rm -p 82:5000 blockchain
    $ docker run --rm -p 83:5000 blockchain
    

    安装(C#实现)

    1. 安装Visual Studio IDE(社区版)的免费副本: https://www.visualstudio.com/vs/
    2. 安装后,使用文件>打开解决方案文件(BlockChain.sln)。打开> Visual Studio中的项目/解决方案菜单选项。
    3. 在“解决方案资源管理器”中,右键单击BlockChain.Console项目并选择“设为启动项目”选项。
    4. 点击“开始”按钮,或点击F5运行。该程序在控制台窗口中执行,并通过HTTP使用与Python版本相同的命令进行控制。

    贡献

    贡献是值得欢迎的!请随时提交合并请求。

主要指標

概覽
名稱與所有者bitcoinj/bitcoinj
主編程語言Java
編程語言Python (語言數: 5)
平台Docker, Linux, Mac, Windows
許可證Apache License 2.0
所有者活动
創建於2013-11-19 04:33:23
推送於2025-06-05 13:58:00
最后一次提交2025-05-24 11:18:57
發布數59
最新版本名稱v0.17 (發布於 2025-02-21 10:38:17)
第一版名稱v0.8 (發布於 2013-04-09 23:24:38)
用户参与
星數5.1k
關注者數306
派生數2.5k
提交數5.4k
已啟用問題?
問題數1251
打開的問題數336
拉請求數503
打開的拉請求數188
關閉的拉請求數1836
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

Learn Blockchains by Building One

Build Status

This is the source code for my post on Building a Blockchain.

Installation

  1. Make sure Python 3.6+ is installed.
  2. Install pipenv.
$ pip install pipenv 
  1. Install requirements
$ pipenv install 
  1. Run the server:
    • $ pipenv run python blockchain.py
    • $ pipenv run python blockchain.py -p 5001
    • $ pipenv run python blockchain.py --port 5002

Docker

Another option for running this blockchain program is to use Docker. Follow the instructions below to create a local Docker container:

  1. Clone this repository
  2. Build the docker container
$ docker build -t blockchain .
  1. Run the container
$ docker run --rm -p 80:5000 blockchain
  1. To add more instances, vary the public port number before the colon:
$ docker run --rm -p 81:5000 blockchain
$ docker run --rm -p 82:5000 blockchain
$ docker run --rm -p 83:5000 blockchain

Installation (C# Implementation)

  1. Install a free copy of Visual Studio IDE (Community Edition):
    https://www.visualstudio.com/vs/

  2. Once installed, open the solution file (BlockChain.sln) using the File > Open > Project/Solution menu options within Visual Studio.

  3. From within the "Solution Explorer", right click the BlockChain.Console project and select the "Set As Startup Project" option.

  4. Click the "Start" button, or hit F5 to run. The program executes in a console window, and is controlled via HTTP with the same commands as the Python version.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.