質問

私は、単純なビットコインマイニングアルゴリズムが単純なC、C#、またはいくつかの疑似言語でどのように機能するかを理解しようとしています。私は例を見つけました http://pastebin.com/EXDsRbYH, しかし残念ながら、それが何をするのかは明らかではありません。実行できませんでした。

入力が 1 つだけあるとします。ビットコインの採掘に使用したいビットコインウォレット「abc...」。1 つの CPU 上の 1 つのスレッドを備えた 1 つのマシンでビットコイン マイニングを実行する、理解しやすいアルゴリズムが必要です [完了までに時間がかかることは承知しています:)]

役に立ちましたか?

解決

非常に愚かで役に立たないものですが、デモ目的でこれを一度実行しました。

from hashlib import md5
from random import random
import sys

# what to hash
data = "Bitcoins!"

# This is just a first run to init the variables 
h = md5(data.encode('utf-8'))
v = h.digest()
best = v
best_i = data
best_vhex = h.hexdigest()

# x ist just a helper to only display
# a subset of all updates (calculates faster)
x = 0
step = 100

# In reality, this loop stops when the "h" hash
# is below a certain threshold (called "difficulty")
while True:
  i = data + str(random())
  h = md5(i.encode('utf-8'))
  v = h.digest()
  vhex = h.hexdigest()

  # log progress
  if v < best or x > step:
    msg = "%-25s | %-25s -> %s" % (i, best_i, best_vhex)
    sys.stdout.write('\r' + msg)
    x = 0
  else:
    x += 1

  # check if new best one
  if v < best:
    best_i, best, best_vhex = i, v, vhex
    print
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top