added forcedifficulty
parent
16f5b69e74
commit
8e1b6e1e7e
|
@ -198,6 +198,8 @@ class API:
|
||||||
resp = Response('\n'.join(self._core.getBlockList()))
|
resp = Response('\n'.join(self._core.getBlockList()))
|
||||||
elif action == 'directMessage':
|
elif action == 'directMessage':
|
||||||
resp = Response(self._core.handle_direct_connection(data))
|
resp = Response(self._core.handle_direct_connection(data))
|
||||||
|
#elif action == 'nodeProof':
|
||||||
|
|
||||||
elif action == 'announce':
|
elif action == 'announce':
|
||||||
if data != '':
|
if data != '':
|
||||||
# TODO: require POW for this
|
# TODO: require POW for this
|
||||||
|
|
|
@ -22,16 +22,19 @@ import nacl.encoding, nacl.hash, nacl.utils, time, math, threading, binascii, lo
|
||||||
import core
|
import core
|
||||||
|
|
||||||
class DataPOW:
|
class DataPOW:
|
||||||
def __init__(self, data, threadCount = 5):
|
def __init__(self, data, forceDifficulty=0, threadCount = 5):
|
||||||
self.foundHash = False
|
self.foundHash = False
|
||||||
self.difficulty = 0
|
self.difficulty = 0
|
||||||
self.data = data
|
self.data = data
|
||||||
self.threadCount = threadCount
|
self.threadCount = threadCount
|
||||||
|
|
||||||
dataLen = sys.getsizeof(data)
|
if forceDifficulty == 0:
|
||||||
self.difficulty = math.floor(dataLen / 1000000)
|
dataLen = sys.getsizeof(data)
|
||||||
if self.difficulty <= 2:
|
self.difficulty = math.floor(dataLen / 1000000)
|
||||||
self.difficulty = 4
|
if self.difficulty <= 2:
|
||||||
|
self.difficulty = 4
|
||||||
|
else:
|
||||||
|
self.difficulty = forceDifficulty
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.data = self.data.encode()
|
self.data = self.data.encode()
|
||||||
|
|
Loading…
Reference in New Issue