forked from LBRYCommunity/lbry-sdk
store loop on storage
This commit is contained in:
parent
2c84b7a7dd
commit
5ca0ebcbb2
1 changed files with 6 additions and 5 deletions
|
@ -132,10 +132,11 @@ class SQLiteStorage(SQLiteMixin):
|
|||
);
|
||||
"""
|
||||
|
||||
def __init__(self, path):
|
||||
def __init__(self, path, loop=None):
|
||||
super().__init__(path)
|
||||
self.content_claim_callbacks = {}
|
||||
self.check_should_announce_lc = None
|
||||
self.loop = loop or asyncio.get_event_loop()
|
||||
|
||||
async def open(self):
|
||||
await super().open()
|
||||
|
@ -219,7 +220,7 @@ class SQLiteStorage(SQLiteMixin):
|
|||
|
||||
def should_single_announce_blobs(self, blob_hashes, immediate=False):
|
||||
def set_single_announce(transaction):
|
||||
now = asyncio.get_event_loop().time()
|
||||
now = self.loop.time()
|
||||
for blob_hash in blob_hashes:
|
||||
if immediate:
|
||||
transaction.execute(
|
||||
|
@ -234,7 +235,7 @@ class SQLiteStorage(SQLiteMixin):
|
|||
|
||||
def get_blobs_to_announce(self):
|
||||
def get_and_update(transaction):
|
||||
timestamp = asyncio.get_event_loop().time()
|
||||
timestamp = self.loop.time()
|
||||
if conf.settings['announce_head_blobs_only']:
|
||||
r = transaction.execute(
|
||||
"select blob_hash from blob "
|
||||
|
@ -784,7 +785,7 @@ class SQLiteStorage(SQLiteMixin):
|
|||
if success:
|
||||
return self.db.execute(
|
||||
"insert or replace into reflected_stream values (?, ?, ?)",
|
||||
(sd_hash, reflector_address, asyncio.get_event_loop().time())
|
||||
(sd_hash, reflector_address, self.loop.time())
|
||||
)
|
||||
return self.db.execute(
|
||||
"delete from reflected_stream where sd_hash=? and reflector_address=?",
|
||||
|
@ -796,7 +797,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 < ?",
|
||||
asyncio.get_event_loop().time() - conf.settings['auto_re_reflect_interval']
|
||||
self.loop.time() - conf.settings['auto_re_reflect_interval']
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue