blockchain_implementation

  • a1_670738
    了解作者
  • 13.1KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-13 07:30
    上传日期
区块链实现 用python实现的简单区块链实现! 尽管它不会将实际的任何内容转移到给定地址,但它实现了区块链的所有基本概念,例如工作证明,挖掘,共识,在交易中生成和验证签名等。了解区块链的最佳方法是构建一个区块链! 运行说明: 首先使用git clone在本地计算机上下载仓库: git clone https://github.com/Adiprogrammer7/blockchain_implementation.git 然后导航到repo并安装依赖项: pip install -r requirements.txt 在config_peers.py添加您希望在运行网络时拥有的对等体。 默认情况下,我们在文件中添加了一些对等体,例如: # store all url's running on the network here in string format, so that t
blockchain_implementation-main.zip
  • blockchain_implementation-main
  • __pycache__
  • main.cpython-37.pyc
    3.1KB
  • config_peers.cpython-37.pyc
    216B
  • blockchain_stuff.cpython-37.pyc
    4.6KB
  • templates
  • make_transaction.html
    1.7KB
  • wallet.txt
    245B
  • blockchain_stuff.py
    5.7KB
  • config_peers.py
    219B
  • main.py
    3.5KB
  • requirements.txt
    44B
  • README.md
    2.7KB
  • .gitignore
    107B
  • generate_wallet.py
    842B
内容介绍
# blockchain_implementation A simple blockchain implemetation with python! Though it won't transfer anything actual to a given address but it implements all the basic concepts of blockchain like proof of work, mining, consensus, generating and validating signature on transaction etc. The best way of understanding the blockchain is by building one! ### Instructions to run: First download the repo on your local machine using git clone: ``` git clone https://github.com/Adiprogrammer7/blockchain_implementation.git ``` Then navigate to repo and install dependencies: ``` pip install -r requirements.txt ``` In the ```config_peers.py``` add the peers you wish to have while running the network. By default we have some peers added to file like: ``` # store all url's running on the network here in string format, so that they can communicate # for example: 'http://127.0.0.1:5000/' peers = {'http://127.0.0.1:5000/', 'http://127.0.0.1:5001/'} ``` We will need a valid private key and public key pair to be able to sign the transaction and make a valid transaction. For that you can run ```generate_wallet.py``` file which will give you a valid private key and public key pair. Now to run, open two terminals and navigate both to repo. Use following commands to run instances of our application: For the first instance on port 5000: ``` set FLASK_APP=main.py flask run --port 5000 --debugger --reload ``` For the second instance on port 5001: ``` set FLASK_APP=main.py flask run --port 5001 --debugger --reload ``` Now we will have two instances running on http://localhost:5000 and http://localhost:5001. ![index](https://user-images.githubusercontent.com/30752980/110203144-67feaa00-7e92-11eb-90f5-3a81a91153af.png) ### How it works: You can find private key and public key pair in ```wallet.txt```, which we generated earlier by running ```generate_wallet.py```. Using that you can make a valid transaction: ![image](https://user-images.githubusercontent.com/30752980/110203408-12c39800-7e94-11eb-8689-76829381c3d4.png) That transaction now can be mined by ```/mine```. For example, http://localhost:5001/mine: ![image](https://user-images.githubusercontent.com/30752980/110203573-e8bea580-7e94-11eb-996b-dc8235725581.png) Just like this you can make multiple transactions and mining will put them in a block which will be added to blockchain of each peer. You can view the entire blockchain on ```/chain``` view. For example, http://localhost:5000/chain: ![image](https://user-images.githubusercontent.com/30752980/110203709-ab0e4c80-7e95-11eb-9640-e9dc48462eb6.png) Also there are other views like ```/peers```, ```/consensus```, ```/unconfirmed_transactions```, etc. **Open to any useful contribution :)**
评论
    相关推荐
    • introduction-to-git:https
      谨慎使用 Git 丸山新平 介绍 本文档旨在以通俗易懂的方式解释 Git 的基本概念和用法。通过阅读本书 易于使用的 Git 你可以使用一个分支 多人可以一起工作 如果你有任何问题,你可以用谷歌找出“我应该查什么词” ...
    • git使用文档
      git使用文档。清晰的pdf版本。一些基础git介绍和使用
    • git 教材 progit
      git资源,不错的git入门教程.适合初学者使用
    • git-kurs:na podstawie https
      git-kurs:na podstawie https
    • Mercurial to Git
      转换脚本 博文链接:https://qianjigui.iteye.com/blog/1561197
    • TVDbLib:httpsGit 克隆
      电视数据库 Git 克隆
    • git-mdp:mdp (https
      git-mdp 用于介绍 git 的甲板
    • git GUI使用
      NULL 博文链接:https://weiliuhong1.iteye.com/blog/2033484
    • kbd:httpsgit.kernel.orgpubscmlinuxkernelgitlegionkbd.git
      git clone git://git.kernel.org/pub/scm/linux/kernel/git/legion/kbd.git NLS(订单翻译) PO文件通过以下方式维护: : 执照 Kbd已获得GNU通用公共许可(GPL)版本2的许可,或根据您的选择选择更高版本的许可。...
    • progit 中文
      progit 中文版,教你如何使用progit来管理项目中的源码.