riecoin support fixes

This commit is contained in:
gatra 2014-03-06 00:14:53 -03:00
parent 05d3f1789a
commit 94276a8132
5 changed files with 19 additions and 19 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
conf/config.py
*.log
LOG
*.bak

View File

@ -68,7 +68,7 @@ class BlockTemplate(halfnode.CBlock):
self.height = data['height']
self.nVersion = data['version']
self.hashPrevBlock = int(data['previousblockhash'], 16)
self.nBits = int(data['bits'], 16)
self.nBits = int(data['bits'], 8)
self.hashMerkleRoot = 0
self.nTime = 0
self.nNonce = 0

View File

@ -341,7 +341,7 @@ class CBlock(object):
if settings.COINDAEMON_ALGO == 'riecoin':
target = settings.POOL_TARGET
else
else:
target = uint256_from_compact(self.nBits)
if settings.COINDAEMON_ALGO == 'riecoin':

View File

@ -248,7 +248,7 @@ class TemplateRegistry(object):
header_bin = job.serialize_header(merkle_root_int, ntime_bin, nonce_bin)
# 4. Reverse header and compare it with target of the user
elif settings.COINDAEMON_ALGO == 'scrypt':
if settings.COINDAEMON_ALGO == 'scrypt':
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))
@ -295,7 +295,7 @@ class TemplateRegistry(object):
# 5. Compare hash with target of the network
isBlockCandidate = False
if settings.COINDAEMON_ALGO == 'riecoin':
if hash_int == 6
if hash_int == 6:
isBlockCandidate = True
else:
if hash_int <= job.target:

View File

@ -212,19 +212,19 @@ def ser_number(n):
return bytes(s)
def isPrime( n )
def isPrime( n ):
if pow( 2, n-1, n ) == 1:
return True
return False
def riecoinPoW( hash_bin, diff, nNonce )
def riecoinPoW( hash_bin, diff, nNonce ):
base = 1 << 8
for i in range(256)
for i in range(256):
base = base << 1
base = base | (hash_bin & 1)
hash_bin = hash_bin >> 1
trailingZeros = diff - 1 - 8 - 256
if trailingZeros < 16 or trailingZeros > 20000
if trailingZeros < 16 or trailingZeros > 20000:
return 0
base = base << trailingZeros
@ -234,30 +234,29 @@ def riecoinPoW( hash_bin, diff, nNonce )
if (base % 210) != 97:
return 0
if !isPrime( base ):
if not isPrime( base ):
return primes
primes++
base += 4
if !isPrime( base ):
return primes
primes++
if isPrime( base ):
primes+=1
base += 2
if isPrime( base ):
primes++
primes+=1
base += 4
if !isPrime( base ):
primes++
if isPrime( base ):
primes+=1
base += 2
if !isPrime( base ):
primes++
if isPrime( base ):
primes+=1
base += 4
if !isPrime( base ):
primes++
if isPrime( base ):
primes+=1
return primes