区块链

  • u4_508385
    了解作者
  • 13.8KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-09 10:39
    上传日期
区块链Python 专案 课堂项目的第1部分 基本设置和工作证明(basic_block_gp) 第1部分带回家的项目 客户端矿工(client_mining_p) 课堂项目的第二部分 基本交易(basic_transactions_gp) 第2部分带回家的项目 基本钱包(basic_wallet_p) 基于dvf的区块链。 在MIT许可下使用: :
Blockchain-master.zip
  • Blockchain-master
  • client_mining_p
  • blockchain.py
    76B
  • README.md
    1.9KB
  • miner.py
    2KB
  • my_id.txt
    15B
  • basic_block_gp
  • blockchain.py
    3.8KB
  • basic_transactions_gp
  • blockchain.py
    77B
  • README.txt
    982B
  • basic_wallet_p
  • README.txt
    781B
  • FAQ.md
    5.5KB
  • Pipfile.lock
    7.8KB
  • README.md
    427B
  • Pipfile
    191B
  • .gitignore
    1.2KB
内容介绍
# Client Miners In the initial blockchain demonstration, we've created a small problem. The `mine` endpoint is called on the server, which means we're the ones spending all of the electricity to generate a new block. This won't do at all! Furthermore, the amount of work needed to actually mine a block is a bit low. We need it to be harder to preserve the integrity of the chain. # Task List *Server* Modify the server we created to: * Remove the `proof_of_work` function from the server. * Change `valid_proof` to require *6* leading zeroes. * Add an endpoint called `last_block` that returns the last block in the chain * Modify the `mine` endpoint to instead receive and validate or reject a new proof sent by a client. * It should accept a POST * Use `data = request.get_json()` to pull the data out of the POST * Note that `request` and `requests` both exist in this project * Check that 'proof', and 'id' are present * return a 400 error using `jsonify(response)` with a 'message' * Return a message indicating success or failure. Remember, a valid proof should fail for all senders except the first. *Client Mining* Create a client application that will: * Get the last block from the server * Run the `proof_of_work` function until a valid proof is found, validating or rejecting each attempt. Use a copy of `valid_proof` to assist. * Print messages indicating that this has started and finished. * Modify it to generate proofs with *6* leading zeroes. * Print a message indicating the success or failure response from the server * Add any coins granted to a simple integer total, and print the amount of coins the client has earned * Continue mining until the app is interrupted. * Change the name in `my_id.txt` to your name * (Stretch) Handle non-json responses sent by the server in the event of an error, without crashing the miner * Stretch: Add a timer to keep track of how long it takes to find a proof
评论
    相关推荐