use loop.time() instead of reactor.seconds() in SQLite storage

This commit is contained in:
Lex Berezhny 2019-01-07 17:26:06 -05:00
parent aeb7c6fe76
commit d30e7cd29e

View file

@ -134,8 +134,6 @@ class SQLiteStorage(SQLiteMixin):
def __init__(self, path):
super().__init__(path)
from twisted.internet import reactor
self.clock = reactor
self.content_claim_callbacks = {}
self.check_should_announce_lc = None
@ -221,7 +219,7 @@ class SQLiteStorage(SQLiteMixin):
def should_single_announce_blobs(self, blob_hashes, immediate=False):
def set_single_announce(transaction):
now = self.clock.seconds()
now = asyncio.get_running_loop().time()
for blob_hash in blob_hashes:
if immediate:
transaction.execute(
@ -236,7 +234,7 @@ class SQLiteStorage(SQLiteMixin):
def get_blobs_to_announce(self):
def get_and_update(transaction):
timestamp = self.clock.seconds()
timestamp = asyncio.get_running_loop().time()
if conf.settings['announce_head_blobs_only']:
r = transaction.execute(
"select blob_hash from blob "
@ -786,7 +784,7 @@ class SQLiteStorage(SQLiteMixin):
if success:
return self.db.execute(
"insert or replace into reflected_stream values (?, ?, ?)",
(sd_hash, reflector_address, self.clock.seconds())
(sd_hash, reflector_address, asyncio.get_running_loop().time())
)
return self.db.execute(
"delete from reflected_stream where sd_hash=? and reflector_address=?",
@ -798,7 +796,7 @@ class SQLiteStorage(SQLiteMixin):
"select s.sd_hash from stream s "
"left outer join reflected_stream r on s.sd_hash=r.sd_hash "
"where r.timestamp is null or r.timestamp < ?",
self.clock.seconds() - conf.settings['auto_re_reflect_interval']
asyncio.get_running_loop().time() - conf.settings['auto_re_reflect_interval']
)