Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Commit

Permalink
Prepare repo for release v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
colonelwatch committed Dec 14, 2020
1 parent c29c1ec commit b002e18
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
File renamed without changes.
13 changes: 5 additions & 8 deletions Multiprocess_nonceMiner.py → mp_miner.py
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b002e18

Please sign in to comment.