forked from LBRYCommunity/lbry-sdk
clean out unused sharding
This commit is contained in:
parent
7bf211a52b
commit
a4058b84ce
1 changed files with 4 additions and 7 deletions
|
@ -822,7 +822,7 @@ class SQLDB:
|
||||||
f"SELECT claim_hash, normalized FROM claim WHERE expiration_height = {height}"
|
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 = """
|
query = """
|
||||||
SELECT claimtrie.claim_hash as is_controlling,
|
SELECT claimtrie.claim_hash as is_controlling,
|
||||||
claimtrie.last_take_over_height,
|
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,
|
(select cr.claim_type from claim cr where cr.claim_hash = claim.reposted_claim_hash) as reposted_claim_type,
|
||||||
claim.*
|
claim.*
|
||||||
FROM claim LEFT JOIN claimtrie USING (claim_hash)
|
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):
|
for claim in self.execute(query):
|
||||||
claim = claim._asdict()
|
claim = claim._asdict()
|
||||||
id_set = set(filter(None, (claim['claim_hash'], claim['channel_hash'], claim['reposted_claim_hash'])))
|
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):
|
def clear_changelog(self):
|
||||||
self.execute("delete from changelog;")
|
self.execute("delete from changelog;")
|
||||||
|
|
||||||
def claim_producer(self, shard=None, total_shards=None):
|
def claim_producer(self):
|
||||||
while self.pending_deletes:
|
while self.pending_deletes:
|
||||||
claim_hash = self.pending_deletes.pop()
|
claim_hash = self.pending_deletes.pop()
|
||||||
yield 'delete', hexlify(claim_hash[::-1]).decode()
|
yield 'delete', hexlify(claim_hash[::-1]).decode()
|
||||||
for claim in self.enqueue_changes(shard, total_shards):
|
for claim in self.enqueue_changes():
|
||||||
yield claim
|
yield claim
|
||||||
self.clear_changelog()
|
self.clear_changelog()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue