diff --git a/onionr/api.py b/onionr/api.py index bf592c59..018f2472 100755 --- a/onionr/api.py +++ b/onionr/api.py @@ -198,6 +198,8 @@ class API: resp = Response('\n'.join(self._core.getBlockList())) elif action == 'directMessage': resp = Response(self._core.handle_direct_connection(data)) + #elif action == 'nodeProof': + elif action == 'announce': if data != '': # TODO: require POW for this diff --git a/onionr/onionrproofs.py b/onionr/onionrproofs.py index 194b37e9..b93d5724 100644 --- a/onionr/onionrproofs.py +++ b/onionr/onionrproofs.py @@ -22,16 +22,19 @@ import nacl.encoding, nacl.hash, nacl.utils, time, math, threading, binascii, lo import core class DataPOW: - def __init__(self, data, threadCount = 5): + def __init__(self, data, forceDifficulty=0, threadCount = 5): self.foundHash = False self.difficulty = 0 self.data = data self.threadCount = threadCount - dataLen = sys.getsizeof(data) - self.difficulty = math.floor(dataLen / 1000000) - if self.difficulty <= 2: - self.difficulty = 4 + if forceDifficulty == 0: + dataLen = sys.getsizeof(data) + self.difficulty = math.floor(dataLen / 1000000) + if self.difficulty <= 2: + self.difficulty = 4 + else: + self.difficulty = forceDifficulty try: self.data = self.data.encode()