Algoritmo simple de minería de bitcoins [cerrado]
Pregunta
Estoy tratando de descubrir cómo funciona el algoritmo simple de minería de Bitcoin en c o c# simple o algún pseudolenguaje.He encontrado un ejemplo en http://pastebin.com/EXDsRbYH, pero desafortunadamente no está claro qué hace.No pude ejecutarlo.
Supongamos que solo tengo una entrada:una billetera Bitcoin "abc..." que me gustaría usar para extraer los Bitcoins.Necesito un algoritmo fácil de entender que realice la extracción de bitcoins en una máquina con un hilo en una CPU [sé que llevará mucho tiempo completarlo :)]
Solución
Súper tonto y bastante inútil, pero una vez hice esto con fines de demostración:
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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow