Commit 61fa401a authored by Vincent Pelletier's avatar Vincent Pelletier

SQUASH Apply part of first review

Mark a line to be folded back once migrated to python 3.
Make storage.database.manager's getFirstTID return the tid packed.
Also, update docstring to stop saying the result is unpacked.
Also, fix None handling in the storage.database.manager and in
master.transaction.
parent 6dffb894
......@@ -215,7 +215,7 @@ class TransactionManager(EventQueue):
def setFirstTID(self, tid):
first_tid = self._first_tid
if first_tid is None or first_tid > tid:
if tid is not None and (first_tid is None or first_tid > tid):
self._first_tid = tid
def getFirstTID(self):
......
......@@ -767,12 +767,17 @@ class DatabaseManager(object):
@requires(_getFirstTID)
def getFirstTID(self):
"""Return tud of first transaction
tids are in unpacked format.
"""
x = self._readable_set
if x:
return min(self._getFirstTID(x) for x in x)
getFirstTID = self._getFirstTID
min_tid = None
for partition in x:
tid = getFirstTID(partition)
if tid is not None and (min_tid is None or tid < min_tid):
min_tid = tid
if min_tid is not None:
return util.p64(min_tid)
def _getLastTID(self, partition, max_tid=None):
"""Return tid of last transaction <= 'max_tid' in given 'partition'
......
......@@ -55,7 +55,7 @@ class InitializationHandler(BaseMasterHandler):
if packed:
self.app.completed_pack_id = pack_id = min(packed.itervalues())
conn.send(Packets.NotifyPackCompleted(pack_id))
last_tid, last_oid = dm.getLastIDs()
last_tid, last_oid = dm.getLastIDs() # PY3
conn.answer(Packets.AnswerLastIDs(last_tid, last_oid, dm.getFirstTID()))
def askPartitionTable(self, conn):
......
......@@ -200,7 +200,7 @@ class StorageDBTests(NeoUnitTestBase):
([oid2], 'user', 'desc', 'ext', False, p64(2), None))
self.assertEqual(self.db.getTransaction(tid1, False), None)
self.assertEqual(self.db.getTransaction(tid2, False), None)
self.assertEqual(self.db.getFirstTID(), u64(tid1))
self.assertEqual(self.db.getFirstTID(), tid1)
self.assertEqual(self.db.getTransaction(tid1, True),
([oid1], 'user', 'desc', 'ext', False, p64(1), None))
self.assertEqual(self.db.getTransaction(tid2, True),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment