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.