Skip to content

Instantly share code, notes, and snippets.

@mecab mecab/stratum.patch
Created Mar 27, 2018

Embed
What would you like to do?
stratum-mining patch for wavi
diff --git a/externals/stratum b/externals/stratum
--- a/externals/stratum
+++ b/externals/stratum
@@ -1 +1 @@
-Subproject commit 8ba1b5fd8a802b981f31dace4cf920cfb4a3907c
+Subproject commit 8ba1b5fd8a802b981f31dace4cf920cfb4a3907c-dirty
diff --git a/lib/halfnode.py b/lib/halfnode.py
index 4ffc017..aca8cc8 100644
--- a/lib/halfnode.py
+++ b/lib/halfnode.py
@@ -26,6 +26,9 @@ if settings.COINDAEMON_ALGO == 'scrypt':
elif settings.COINDAEMON_ALGO == 'quark':
log.debug("########################################### Loading Quark Support #########################################################")
import quark_hash
+elif settings.COINDAEMON_ALGO == 'wavi_yescrypt':
+ log.debug("########################################### Loading Yescrypt Support #########################################################")
+ import wavi_yescrypt
else:
log.debug("########################################### Loading SHA256 Support ######################################################")
@@ -241,6 +244,8 @@ class CBlock(object):
self.quark = None
elif settings.COINDAEMON_ALGO == 'riecoin':
self.riecoin = None
+ elif settings.COINDAEMON_ALGO == 'wavi_yescrypt':
+ self.wavi_yescrypt = None
else: pass
if settings.COINDAEMON_Reward == 'POS':
self.signature = b""
@@ -282,7 +287,19 @@ class CBlock(object):
else: pass
return ''.join(r)
- if settings.COINDAEMON_ALGO == 'scrypt':
+ if settings.COINDAEMON_ALGO == 'wavi_yescrypt':
+ def calc_wavi_yescrypt(self):
+ if self.wavi_yescrypt is None:
+ r = []
+ r.append(struct.pack("<i", self.nVersion))
+ r.append(ser_uint256(self.hashPrevBlock))
+ r.append(ser_uint256(self.hashMerkleRoot))
+ r.append(struct.pack("<I", self.nTime))
+ r.append(struct.pack("<I", self.nBits))
+ r.append(struct.pack("<I", self.nNonce))
+ self.wavi_yescrypt = uint256_from_str(wavi_yescrypt.getPoWHash(''.join(r)))
+ return self.wavi_yescrypt
+ elif settings.COINDAEMON_ALGO == 'scrypt':
def calc_scrypt(self):
if self.scrypt is None:
r = []
@@ -333,7 +350,9 @@ class CBlock(object):
def is_valid(self):
- if settings.COINDAEMON_ALGO == 'riecoin':
+ if settings.COINDAEMON_ALGO == 'wavi_yescrypt':
+ self.calc_wavi_yescrypt()
+ elif settings.COINDAEMON_ALGO == 'riecoin':
self.calc_riecoin()
elif settings.COINDAEMON_ALGO == 'scrypt':
self.calc_scrypt()
@@ -347,6 +366,9 @@ class CBlock(object):
else:
target = uint256_from_compact(self.nBits)
+ if settings.COINDAEMON_ALGO == 'wavi_yescrypt':
+ if self.wavi_yescrypt > target:
+ return False
if settings.COINDAEMON_ALGO == 'riecoin':
if self.riecoin < target:
return False
diff --git a/lib/template_registry.py b/lib/template_registry.py
index 4202190..b9083db 100644
--- a/lib/template_registry.py
+++ b/lib/template_registry.py
@@ -11,6 +11,8 @@ elif settings.COINDAEMON_ALGO == 'quark':
import quark_hash
elif settings.COINDAEMON_ALGO == 'skeinhash':
import skeinhash
+elif settings.COINDAEMON_ALGO == 'wavi_yescrypt':
+ import wavi_yescrypt
else: pass
from twisted.internet import defer
from lib.exceptions import SubmitException
@@ -154,6 +156,8 @@ class TemplateRegistry(object):
diff1 = 0x0000ffff00000000000000000000000000000000000000000000000000000000
elif settings.COINDAEMON_ALGO == 'scrypt-jane':
diff1 = 0x0000ffff00000000000000000000000000000000000000000000000000000000
+ elif settings.COINDAEMON_ALGO == 'wavi_yescrypt':
+ diff1 = 0x0000ffff00000000000000000000000000000000000000000000000000000000
elif settings.COINDAEMON_ALGO == 'quark':
diff1 = 0x000000ffff000000000000000000000000000000000000000000000000000000
elif settings.COINDAEMON_ALGO == 'riecoin':
@@ -257,6 +261,8 @@ class TemplateRegistry(object):
hash_bin = ltc_scrypt.getPoWHash(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]))
elif settings.COINDAEMON_ALGO == 'scrypt-jane':
hash_bin = yac_scrypt.getPoWHash(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]), int(ntime, 16))
+ elif settings.COINDAEMON_ALGO == 'wavi_yescrypt':
+ hash_bin = wavi_yescrypt.getPoWHash(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]))
elif settings.COINDAEMON_ALGO == 'quark':
hash_bin = quark_hash.getPoWHash(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]))
elif settings.COINDAEMON_ALGO == 'skeinhash':
@@ -285,6 +291,8 @@ class TemplateRegistry(object):
if hash_int < target_user:
raise SubmitException("Share does not meet target")
else:
+ log.debug("%064x" % hash_int)
+ log.debug("%064x" % target_user)
if hash_int > target_user:
raise SubmitException("Share is above target")
# Mostly for debugging purposes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.