-3

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

入力が1つだけだとします。ビットコインのマイニングに使用したいビットコインウォレット「abc...」です。1つのCPUで1つのスレッドを使用して1つのマシンでビットコインマイニングを実行するアルゴリズムを理解するのが簡単である必要があります[完了するまでに何年もかかることを知っています:)]

4

1 に答える 1

4

非常に馬鹿げていて、かなり役に立たないが、私はこれをデモ目的で一度行った。

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
于 2012-03-03T10:35:07.933 に答える