diff --git a/onionr/communicator.py b/onionr/communicator.py index ec4b5e7b..a1416e5f 100755 --- a/onionr/communicator.py +++ b/onionr/communicator.py @@ -106,6 +106,7 @@ class OnionrCommunicate: logger.warn("Peer " + i + " returned malformed hash") blockList = blocks.split('\n') for i in blockList: + logger.debug('Exchanged block (blockList): ' + i) if not self._utils.validateHash(i): # skip hash if it isn't valid logger.warn('Hash ' + i + ' is not valid') diff --git a/onionr/core.py b/onionr/core.py index 0bb26919..e364775e 100644 --- a/onionr/core.py +++ b/onionr/core.py @@ -130,15 +130,19 @@ class Core: ''') conn.commit() conn.close() - def addToBlockDB(self, newHash): + def addToBlockDB(self, newHash, selfInsert=False): '''add a hash value to the block db (should be in hex format)''' if not os.path.exists(self.blockDB): raise Exception('Block db does not exist') conn = sqlite3.connect(self.blockDB) c = conn.cursor() currentTime = math.floor(time.time()) - data = (newHash, currentTime, 0, 0) - c.execute('INSERT into hashes values(?, ?, ?, ?);', data) + if selfInsert: + selfInsert = 1 + else: + selfInsert = 0 + data = (newHash, currentTime, 0, 0, selfInsert) + c.execute('INSERT into hashes values(?, ?, ?, ?, ?);', data) conn.commit() conn.close() diff --git a/onionr/onionr.py b/onionr/onionr.py index f294b56c..b84d1633 100755 --- a/onionr/onionr.py +++ b/onionr/onionr.py @@ -114,7 +114,8 @@ class Onionr: messageToAdd = input('Broadcast message to network: ') if len(messageToAdd) >= 1: break - self.onionrCore.setData(messageToAdd) + addedHash = self.onionrCore.setData(messageToAdd) + self.onionrCore.addToBlockDB(addedHash, selfInsert=True) elif command == 'stats': self.showStats() elif command == 'help' or command == '--help':