pow changes
This commit is contained in:
parent
3fc623b8ee
commit
950883dc5d
@ -18,10 +18,11 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
'''
|
||||
|
||||
import onionrexceptions, onionrpeers, onionrproofs, logger, onionrusers
|
||||
import onionrexceptions, onionrpeers, onionrproofs, logger
|
||||
import base64, sqlite3, os
|
||||
from dependencies import secrets
|
||||
from utils import netutils
|
||||
from onionrusers import onionrusers
|
||||
|
||||
class DaemonTools:
|
||||
'''
|
||||
|
@ -44,6 +44,10 @@ class PasswordStrengthError(Exception):
|
||||
pass
|
||||
|
||||
# block exceptions
|
||||
|
||||
class DifficultyTooLarge(Exception):
|
||||
pass
|
||||
|
||||
class InvalidMetadata(Exception):
|
||||
pass
|
||||
|
||||
|
@ -69,6 +69,7 @@ def getDifficultyForNewBlock(data, ourBlock=True):
|
||||
minDifficulty = config.get('general.minimum_block_pow', 4)
|
||||
|
||||
retData = max(minDifficulty, math.floor(dataSize / 100000)) + getDifficultyModifier()
|
||||
|
||||
return retData
|
||||
|
||||
def getHashDifficulty(h):
|
||||
@ -245,11 +246,10 @@ class POW:
|
||||
answer = ''
|
||||
heartbeat = 200000
|
||||
hbCount = 0
|
||||
|
||||
nonce = int(binascii.hexlify(nacl.utils.random(2)), 16)
|
||||
while self.hashing:
|
||||
rand = nacl.utils.random()
|
||||
#token = nacl.hash.blake2b(rand + self.data).decode()
|
||||
self.metadata['powRandomToken'] = base64.b64encode(rand).decode()
|
||||
self.metadata['powRandomToken'] = nonce
|
||||
payload = json.dumps(self.metadata).encode() + b'\n' + self.data
|
||||
token = myCore._crypto.sha3Hash(payload)
|
||||
try:
|
||||
@ -262,6 +262,7 @@ class POW:
|
||||
iFound = True
|
||||
self.result = payload
|
||||
break
|
||||
nonce += 1
|
||||
|
||||
if iFound:
|
||||
endTime = math.floor(time.time())
|
||||
|
Loading…
Reference in New Issue
Block a user