From b002e188904ece740b2e457e0acc62765cc65646 Mon Sep 17 00:00:00 2001 From: Kenny Peng Date: Mon, 14 Dec 2020 12:17:12 -0800 Subject: [PATCH] Prepare repo for release v1.0 --- README.md | 4 ++-- Minimal_PC_Miner.py => minimal_miner.py | 0 Multiprocess_nonceMiner.py => mp_miner.py | 13 +++++-------- 3 files changed, 7 insertions(+), 10 deletions(-) rename Minimal_PC_Miner.py => minimal_miner.py (100%) rename Multiprocess_nonceMiner.py => mp_miner.py (86%) diff --git a/README.md b/README.md index d20c901..2bb9265 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,6 @@ A quick casual project I wrote to try out applying hash midstate caching on the cryptocurrency project [duino-coin](https://github.com/revoxhere/duino-coin). The idea is to cache the SHA-1 algorithm's state after it processes the prefix (creating the midstate) then to finish the hash with the guessed nonces repeatedly, but while reusing the midstate, until the right nonce is found. This saves a lot of calculation, and it's already being used in Bitcoin mining. -Running Multiprocess_nonceMiner.py with `N_PROCESSES = 128`, my i7-8550U peaked at 16 MH/s. In other words, it's probably the fastest DUCO-S1 miner around, barring GPUs. If you're monitoring your own hash rate, make sure you're getting a command line output every two seconds, or else the rate inaccurately appears high (I've had lag for some reason when I pinned the CPU too hard and for too long). +Running Multiprocess_nonceMiner.py with `N_PROCESSES = 128`, my i7-8550U peaked at 16 MH/s. In other words, it's probably the fastest DUCO-S1 miner around, barring GPUs. To try it out yourself, grab a release! Then in the nonceMiner_release folder, just run the command `python ./mp_miner.py username processes` in Windows or `python3 ./mp_miner.py username processes` in Linux, replacing `username` with your Duino-coin username and `processes` with the number of processes (128 recommended, 64 recommended for less powerful machines). -The "src" folder contains C code that implements the shortcut and also a Cython wrapper, so C/C++ programmers can use those source files. This includes an unmodified copy of [sha1](https://github.com/clibs/sha1). For Python programmers, I also attached a precompiled extension (nonceMiner.cp38-win_amd64.pyd) in the root of this repo—the examples hook into this. It's only built in Windows though, so run `python setup.py build_ext --inplace` if you have another OS. +The "src" folder contains C code that implements the shortcut and also a Cython wrapper, so C/C++ programmers can use those source files. This includes an unmodified copy of [sha1](https://github.com/clibs/sha1). Python programmers can grab the precompiled extension from a release. However, cloning this repo will require compiling it from scratch. This means you will need to install Cython and Visual Studio Build Tools 2019 in Windows, or just Cython in Linux. From there, just run `make windows` or `make linux-gnu`. \ No newline at end of file diff --git a/Minimal_PC_Miner.py b/minimal_miner.py similarity index 100% rename from Minimal_PC_Miner.py rename to minimal_miner.py diff --git a/Multiprocess_nonceMiner.py b/mp_miner.py similarity index 86% rename from Multiprocess_nonceMiner.py rename to mp_miner.py index 25037c2..8781169 100644 --- a/Multiprocess_nonceMiner.py +++ b/mp_miner.py @@ -1,18 +1,16 @@ -import socket, urllib.request, time # Python 3 included +import socket, urllib.request, time, sys # Python 3 included import multiprocessing as mp # Also Python 3 included -import psutil # Install with 'pip install psutil' import nonceMiner -username = 'travelmode' - -N_PROCESSES = 64 # I've found 128 is better performance but will glitch the hashrate counter +USERNAME = sys.argv[1] +N_PROCESSES = int(sys.argv[2]) serverip = 'https://raw.githubusercontent.com/revoxhere/duino-coin/gh-pages/serverip.txt' pool_location = urllib.request.urlopen(serverip).read().decode().splitlines() pool_ip = pool_location[0] pool_port = int(pool_location[1]) -job_request_bytes = ('JOB,'+username).encode('utf-8') +job_request_bytes = ('JOB,'+USERNAME).encode('utf-8') def mineDUCO(hashcount, accepted, rejected): soc = socket.socket() @@ -27,7 +25,6 @@ def mineDUCO(hashcount, accepted, rejected): target_bytes = job[1].encode('ascii') difficulty = int(job[2]) - # threaded mining means the result no longer equals the hashcount! result = nonceMiner.c_mine_DUCO_S1(prefix_bytes, target_bytes, difficulty) soc.send(str(result).encode('utf-8')) # Send result of hashing algorithm to pool @@ -71,7 +68,7 @@ def mineDUCO(hashcount, accepted, rejected): rejected_in_2s = rejected.value rejected.value = 0 - print('Hash rate: %.2f' % (hash_in_2s/1000000/(current_time-past_time)), 'MH/s with a CPU usage of', psutil.cpu_percent()) + print('Hash rate: %.2f' % (hash_in_2s/1000000/(current_time-past_time)), 'MH/s') print('Accepted shares in 2s:', accepted_in_2s, '\tRejected shares in 2s:', rejected_in_2s) print() past_time = current_time