Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: revoxhere/duino-coin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4.0
Choose a base ref
...
head repository: revoxhere/duino-coin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
102 changes: 58 additions & 44 deletions AVR_Miner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
"""
Duino-Coin Official AVR Miner 4.0 © MIT licensed
Duino-Coin Official AVR Miner 4.3 © MIT licensed
https://duinocoin.com
https://github.com/revoxhere/duino-coin
Duino-Coin Team & Community 2019-2024
@@ -27,18 +27,16 @@
from datetime import datetime
from statistics import mean
from signal import SIGINT, signal
from collections import deque
from time import ctime, sleep, strptime, time
import pip

from subprocess import DEVNULL, Popen, check_call, call
from threading import Thread
from threading import Lock as thread_lock
from threading import Semaphore

from threading import Thread, Lock
import base64 as b64

import os
printlock = Semaphore(value=1)

printlock = Lock()


# Python <3.5 check
@@ -109,15 +107,16 @@ def port_num(com):


class Settings:
VER = '4.0'
SOC_TIMEOUT = 15
REPORT_TIME = 120
VER = '4.3'
SOC_TIMEOUT = 10
REPORT_TIME = 300
AVR_TIMEOUT = 10
BAUDRATE = 115200
DATA_DIR = "Duino-Coin AVR Miner " + str(VER)
SEPARATOR = ","
ENCODING = "utf-8"
TEMP_FOLDER = "Temp"
disable_title = False

try:
# Raspberry Pi latin users can't display this character
@@ -266,6 +265,16 @@ def check_updates():
print(e)
sys.exit()


def has_mining_key(username):
response = requests.get(
"https://server.duinocoin.com/mining_key"
+ "?u=" + username,
timeout=10
).json()
return response["has_key"]


def check_mining_key(user_settings):
user_settings = user_settings["AVR Miner"]

@@ -280,6 +289,7 @@ def check_mining_key(user_settings):
+ key,
timeout=10
).json()
debug_output(response)

if response["success"] and not response["has_key"]: # if the user doesn't have a mining key
user_settings["mining_key"] = "None"
@@ -294,6 +304,10 @@ def check_mining_key(user_settings):
return

if not response["success"]:
if response["message"] == "Too many requests":
debug_output("Skipping mining key check - getting 429")
return

if user_settings["mining_key"] == "None":
pretty_print(
"sys0",
@@ -457,8 +471,8 @@ def start(donation_level):


shares = [0, 0, 0]
hashrate_mean = []
ping_mean = []
hashrate_mean = deque(maxlen=25)
ping_mean = deque(maxlen=25)
diff = 0
donator_running = False
job = ''
@@ -515,6 +529,8 @@ def start(donation_level):
lang = 'italian'
elif locale.startswith('pt'):
lang = 'portuguese'
if locale.startswith("zh_TW"):
lang = "chinese_Traditional"
elif locale.startswith('zh'):
lang = 'chinese_simplified'
elif locale.startswith('th'):
@@ -582,24 +598,26 @@ def debug_output(text: str):


def title(title: str):
if osname == 'nt':
"""
Changing the title in Windows' cmd
is easy - just use the built-in
title command
"""
ossystem('title ' + title)
else:
"""
Most *nix terminals use
this escape sequence to change
the console window title
"""
try:
print('\33]0;' + title + '\a', end='')
sys.stdout.flush()
except Exception as e:
print(e)
if not Settings.disable_title:
if osname == 'nt':
"""
Changing the title in Windows' cmd
is easy - just use the built-in
title command
"""
ossystem('title ' + title)
else:
"""
Most *nix terminals use
this escape sequence to change
the console window title
"""
try:
print('\33]0;' + title + '\a', end='')
sys.stdout.flush()
except Exception as e:
debug_output("Error setting title: " +str(e))
Settings.disable_title = True


def handler(signal_received, frame):
@@ -651,13 +669,8 @@ def load_config():
if not correct_username:
print(get_string("incorrect_username"))

response = requests.get(
"https://server.duinocoin.com/mining_key"
+ "?u=" + username, timeout=10
).json()

mining_key = "None"
if response["has_key"]:
if has_mining_key(username):
mining_key = input(Style.RESET_ALL + Fore.YELLOW
+ get_string("ask_mining_key")
+ Fore.RESET + Style.BRIGHT)
@@ -740,10 +753,10 @@ def load_config():
'language': lang,
'identifier': rig_identifier,
'debug': 'n',
"soc_timeout": 45,
"soc_timeout": 10,
"avr_timeout": 10,
"discord_presence": "y",
"periodic_report": 60,
"periodic_report": 300,
"mining_key": mining_key}

with open(str(Settings.DATA_DIR)
@@ -1171,7 +1184,7 @@ def mine_avr(com, threadid, fastest_pool, thread_rigid):
hashrate_t = round(num_res / computetime, 2)

hashrate_mean.append(hashrate_t)
hashrate = mean(hashrate_mean[-5:])
hashrate = mean(hashrate_mean)
hashrate_list[threadid] = hashrate
total_hashrate = sum(hashrate_list)
except Exception as e:
@@ -1201,7 +1214,7 @@ def mine_avr(com, threadid, fastest_pool, thread_rigid):
time_delta = (responsetimestop -
responsetimetart).microseconds
ping_mean.append(round(time_delta / 1000))
ping = mean(ping_mean[-10:])
ping = mean(ping_mean)
diff = get_prefix("", int(diff), 0)
debug_output(com + f': retrieved feedback: {" ".join(feedback)}')
except Exception as e:
@@ -1239,7 +1252,7 @@ def mine_avr(com, threadid, fastest_pool, thread_rigid):

if shares[0] % 100 == 0 and shares[0] > 1:
pretty_print("sys0",
f"{get_string('surpassed')} {accept.value} {get_string('surpassed_shares')}",
f"{get_string('surpassed')} {shares[0]} {get_string('surpassed_shares')}",
"success")

title(get_string('duco_avr_miner') + str(Settings.VER)
@@ -1305,9 +1318,10 @@ def print_queue_handler():
while True:
if len(print_queue):
message = print_queue[0]
del print_queue[0]
print(message)
sleep(0.1)
with printlock:
print(message)
print_queue.pop(0)
sleep(0.01)


if __name__ == '__main__':
12 changes: 7 additions & 5 deletions Arduino_Code/Arduino_Code.ino
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
( _ \( )( )(_ _)( \( )( _ )___ / __)( _ )(_ _)( \( )
)(_) ))(__)( _)(_ ) ( )(_)((___)( (__ )(_)( _)(_ ) (
(____/(______)(____)(_)\_)(_____) \___)(_____)(____)(_)\_)
Official code for Arduino boards (and relatives) version 4.0
Official code for Arduino boards (and relatives) version 4.3
Duino-Coin Team & Community 2019-2024 © MIT Licensed
https://duinocoin.com
@@ -20,6 +20,8 @@ for default settings use -O0. -O may be a good tradeoff between both */
#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#endif
#define SEP_TOKEN ","
#define END_TOKEN "\n"
/* For 8-bit microcontrollers we should use 16 bit variables since the
difficulty is low, for all the other cases should be 32 bits. */
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR)
@@ -126,7 +128,7 @@ void loop() {
uintDiff difficulty = strtoul(Serial.readStringUntil(',').c_str(), NULL, 10);
// Clearing the receive buffer reading one job.
while (Serial.available()) Serial.read();
// Turn on the built-in led
// Turn off the built-in led
#if defined(ARDUINO_ARCH_AVR)
PORTB = PORTB | B00100000;
#else
@@ -154,9 +156,9 @@ void loop() {

// Send result back to the program with share time
Serial.print(String(ducos1result, 2)
+ ","
+ SEP_TOKEN
+ String(elapsedTime, 2)
+ ","
+ SEP_TOKEN
+ String(DUCOID)
+ "\n");
+ END_TOKEN);
}
4 changes: 1 addition & 3 deletions Arduino_Code/duco_hash.cpp
Original file line number Diff line number Diff line change
@@ -77,9 +77,7 @@ void duco_hash_block(duco_hash_state_t * hasher) {
}

void duco_hash_init(duco_hash_state_t * hasher, char const * prevHash) {
for (uint8_t i = 0; i < 40; i++) {
hasher->buffer[i] = prevHash[i];
}
memcpy(hasher->buffer, prevHash, 40);

if (prevHash == (void*)(0xffffffff)) {
// NOTE: THIS IS NEVER CALLED
11 changes: 10 additions & 1 deletion ESP_Code/Dashboard.h
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ const char WEBSITE[] PROGMEM = R"=====(
<!--
Duino-Coin self-hosted dashboard
MIT licensed
The Duino-Coin Team, 2019-2023
The Duino-Coin Team, 2019-present
https://github.com/revoxhere/duino-coin
https://duinocoin.com
-->
@@ -112,6 +112,14 @@ const char WEBSITE[] PROGMEM = R"=====(
Miner version
</div>
</div>
<div class="column" style="min-width:15em">
<div class="title is-size-5 mb-0">
@@SENSOR@@
</div>
<div class="heading is-size-5">
Sensor reading(s)
</div>
</div>
</div>
</div>
</div>
@@ -131,6 +139,7 @@ const char WEBSITE[] PROGMEM = R"=====(
<a href="https://github.com/revoxhere/duino-coin">
github.com/revoxhere/duino-coin
</a>
@@RESET_SETTINGS@@
</div>
</div>
</div>
Loading