Skip to content

Commit

Permalink
Updated the miner.py
Browse files Browse the repository at this point in the history
- Removed venv requirment
/ Marked venv as optional step
+ Added hashrate convertor
+ Fixed bug with hasher don't stop when someone else found block
+ Added warning miner exit dont work propperly on windows
  • Loading branch information
tommarekCZE committed Aug 8, 2024
1 parent 521d2ad commit 4fccd0a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 15 deletions.
17 changes: 8 additions & 9 deletions MINERSETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Welcome to the official page of ElaptaCoin Proof of Work Miner!
5. **Auto Package Install** - The miner auto install all required packages

#### Platform support
1. Windows 10/11 (Theoretically Windows 7)
1. Windows 10/11 (Theoretically Windows 7) **(Issues while exiting miner! Use Taskmgr!)**
2. Linux x32/x64
3. ARM x64 (AArch64)

Expand All @@ -35,9 +35,10 @@ You can find the latest release on https://github.com/DuckyPolice/Elaptacoin-PUB

### 4. Open the Un-ZIPed directory in Powershell

### 5. Create and Enter Python virtualenv
### 5. (OPTIONAL) Create and Enter Python virtualenv
**>>>If you are having any issues with miner, try use virtualenv!<<<**

**Virtualenv should be part of python, if you don't have it you can install the virtualenv by `pip3.9 install virtualenv` or `python3.8 -m venv venv`
Virtualenv should be part of python, if you don't have it you can install the virtualenv by `pip3.9 install virtualenv` or `python3.8 -m venv venv`

Type `python3.9 -m venv venv` or `python3.8 -m venv venv` to create virtualenv

Expand All @@ -46,8 +47,6 @@ Then type `venv\Scripts\Activate.ps1` in order to activate virtualenv
Make sure there is `(.venv)` before path in powershell

### 6. Run the miner
**You can use `python` now. Because if the virtualenv is activated the `pyhon` refers to the python in the virtualenv**

To run the miner type `python miner.py` or `python3.9 miner.py` or `python3.8 miner.py`

And Enjoy! If experience some errors let us know on our discord server!
Expand Down Expand Up @@ -88,9 +87,11 @@ We recomend to place the directory with miner to user folder

### 4. Open the Un-ZIPed directory in bash

### 5. Create and Enter Python virtualenv
### 5. (OPTIONAL) Create and Enter Python virtualenv
**>>>If you are having any issues with miner, try use virtualenv!<<<**


**Virtualenv should be part of python, if you don't have it you can install the virtualenv by `pip3.9 install virtualenv` or `python3.8 -m venv venv`
Virtualenv should be part of python, if you don't have it you can install the virtualenv by `pip3.9 install virtualenv` or `python3.8 -m venv venv`

Type `python3.9 -m venv venv` or `python3.8 -m venv venv` to create virtualenv

Expand All @@ -99,8 +100,6 @@ Then type `source myvenv/bin/activate` in order to activate virtualenv
Make sure there is `(.venv)` before path in bash

### 6. Run the miner
**You can use `python` now. Because if the virtualenv is activated the `pyhon` refers to the python in the virtualenv**

**The miner needs to be executed by sudo privileges!**

To run the miner type `python miner.py` or `python3.9 miner.py` or `python3.8 miner.py`
Expand Down
30 changes: 24 additions & 6 deletions miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
key_pressed = False
globalFind = False
hasherName = "EXAvatorNT"
hasherSub = None

def is_venv():
return (hasattr(sys, 'real_prefix') or
Expand Down Expand Up @@ -60,7 +61,7 @@ def check_for_sudo():

check_for_sudo()
check_python_ver()
check_inside_venv()
#check_inside_venv()

def install(package):
try:
Expand Down Expand Up @@ -128,8 +129,12 @@ def kill(self):
mineThread = thread_with_trace()

def terminateMining():
global mineThread
global mineThread, hasherSub
mineThread.kill()
try:
hasherSub.terminate()
except:
pass

def dummy():
1+1
Expand Down Expand Up @@ -212,11 +217,23 @@ def fetch_or_create_config():

return username

def format_hashrate(rate):
units = ["H/s", "kH/s", "MH/s", "GH/s", "TH/s", "PH/s", "EH/s", "ZH/s", "YH/s"]
power = 0

while rate >= 1000 and power < len(units) - 1:
rate /= 1000
power += 1

return f"{rate:.2f} {units[power]}"

def getNetworkData(type):
if type == 1:
return "193.86.97.192"
elif type == 2:
return 12345
elif type == 3:
return "10.10.0.60"

def enterExit():
global running, spinning, closeage, lock
Expand Down Expand Up @@ -330,15 +347,16 @@ def fetch(client):
create_thread(stopAll)

def mine(client):
global prev_hash, diff, user, spinning, hasherName, lock
global prev_hash, diff, user, spinning, hasherName, lock, hasherSub
if lock == True:
return
pretty_print(f"Started mining, <--JOB INFO--> PREVIOUS BLOCK> {prev_hash} / DIFFICULTY> {difficulty_to_int(len(diff))}", "info", "JOB")
create_thread(spinning_cursor_thread)
try:
args = [prev_hash, diff]
result = subprocess.run([hasherName] + args, capture_output=True, text=True)
out = result.stdout.split(",")
hasherSub = subprocess.Popen([hasherName] + args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
stdout, stderr = hasherSub.communicate()
out = stdout.strip().split(",")
spinning = False
if out[0] == "error":
raise Exception(out[1])
Expand All @@ -347,7 +365,7 @@ def mine(client):
increment = out[2]
took = out[3]
hashrate = out[4]
pretty_print(f"Block was found in {took} with hashrate of {hashrate} H/s! Sending for rewiev..., BLOCK> {hash} / NONCE> {increment}", "warn", "JOB".replace('\n', ' '))
pretty_print(f"Block was found in {took} with hashrate of {format_hashrate(int(float(hashrate)))}! Sending for rewiev..., BLOCK> {hash} / NONCE> {increment}", "warn", "JOB".replace('\n', ' '))
client.send(bytes(f"SUBMIT,{hash},{increment},{user}", encoding="utf8"))
terminateMining()
else:
Expand Down

0 comments on commit 4fccd0a

Please sign in to comment.