clean out unused sharding

This commit is contained in:
Victor Shyba 2021-05-07 12:00:30 -03:00
parent 7bf211a52b
commit a4058b84ce

View file

@ -822,7 +822,7 @@ class SQLDB:
f"SELECT claim_hash, normalized FROM claim WHERE expiration_height = {height}"
)
def enqueue_changes(self, shard=None, total_shards=None):
def enqueue_changes(self):
query = """
SELECT claimtrie.claim_hash as is_controlling,
claimtrie.last_take_over_height,
@ -832,11 +832,8 @@ class SQLDB:
(select cr.claim_type from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_claim_type,
claim.*
FROM claim LEFT JOIN claimtrie USING (claim_hash)
WHERE claim.claim_hash in (SELECT claim_hash FROM changelog)
"""
if shard is not None and total_shards is not None:
query += f" WHERE claim.height % {total_shards} = {shard}"
else:
query += " WHERE claim.claim_hash in (SELECT claim_hash FROM changelog)"
for claim in self.execute(query):
claim = claim._asdict()
id_set = set(filter(None, (claim['claim_hash'], claim['channel_hash'], claim['reposted_claim_hash'])))
@ -864,11 +861,11 @@ class SQLDB:
def clear_changelog(self):
self.execute("delete from changelog;")
def claim_producer(self, shard=None, total_shards=None):
def claim_producer(self):
while self.pending_deletes:
claim_hash = self.pending_deletes.pop()
yield 'delete', hexlify(claim_hash[::-1]).decode()
for claim in self.enqueue_changes(shard, total_shards):
for claim in self.enqueue_changes():
yield claim
self.clear_changelog()