1 Star 0 Fork 2

Aaron_ou/DataChain

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
miner.py 938 Bytes
一键复制 编辑 原始数据 按行查看 历史
Aaron_ou 提交于 2018-02-07 17:07 . finish beta vision1
# -*- coding:UTF-8 -*-
"""
矿工专用
"""
from urllib import request
import hashlib
import json
class miner():
def __init__(self):
pass
def get_data(self,address):
re = request.Request(address)
with request.urlopen(re) as f:
data_json = f.read()
data = json.loads(data_json.decode())
return data
def cal_data(self,data):
re = 0
i = 1
while(re == 0):
cal = hashlib.sha256()
cal.update((data+str(i)).encode("utf-8"))
res = cal.hexdigest()
if (res[-3:] == '000'):
re = 1
else:
i = i + 1
print(res)
return i
def respone(self):
pass
if __name__ == '__main__':
m = miner()
y = []
data = m.get_data("http://localhost:8080/get_data")
print(data[0])
for x in data:
y.append(m.cal_data(x))
print(y)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/Aaron_ou/DataChain.git
git@gitee.com:Aaron_ou/DataChain.git
Aaron_ou
DataChain
DataChain
master

搜索帮助