Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import random
import string
import sqlite3
import threading
import multiprocessing

NUM_CPUS=8

def check_difficulty():
db = sqlite3.connect("nodes.db")
Expand All @@ -29,7 +31,7 @@ def check_difficulty():

def check_coin(data):
node = sqlite3.connect("nodes.db")
node = node.execute("SELECT ip, port FROM data WHERE relay=?", [True])
node = node.execute("SELECT ip, port FROM data WHERE relay=?", [True])
node = node.fetchall()
random.shuffle(node)
for x in node:
Expand All @@ -55,7 +57,7 @@ def mine():
while True:
# print starter+str(on)
c = hashlib.sha512(starter+str(on)).hexdigest()
startswith = "1"*check['difficulty']
startswith = "1"*check['difficulty']
if c.startswith(startswith):
print c
wall = sqlite3.connect("wallet.db")
Expand All @@ -66,6 +68,6 @@ def mine():
else:
on += 1

for x in range(15):
threading.Thread(target=mine).start()
for x in range(NUM_CPUS):
multiprocessing.Process(target=mine).start()
#mine()