forked from LBRYCommunity/lbry-sdk
handle claims in abandoned channels
This commit is contained in:
parent
24a88db595
commit
7a4e5dcb05
5 changed files with 32 additions and 8 deletions
|
@ -27,7 +27,7 @@ def get_best_block_height_for_file(file_number):
|
||||||
)['height']
|
)['height']
|
||||||
|
|
||||||
|
|
||||||
@event_emitter("blockchain.sync.block.file", "blocks", "txs", throttle=50)
|
@event_emitter("blockchain.sync.block.file", "blocks", "txs", throttle=100)
|
||||||
def sync_block_file(
|
def sync_block_file(
|
||||||
file_number: int, start_height: int, txs: int, flush_size: int, p: ProgressContext
|
file_number: int, start_height: int, txs: int, flush_size: int, p: ProgressContext
|
||||||
):
|
):
|
||||||
|
|
|
@ -31,7 +31,7 @@ TREND_MAIN_EVENT = Event.add("blockchain.sync.trends.main", "blocks")
|
||||||
|
|
||||||
class BlockchainSync(Sync):
|
class BlockchainSync(Sync):
|
||||||
|
|
||||||
TX_FLUSH_SIZE = 20_000 # flush to db after processing this many TXs and update progress
|
TX_FLUSH_SIZE = 100_000 # flush to db after processing this many TXs and update progress
|
||||||
FILTER_CHUNK_SIZE = 100_000 # split filter generation tasks into this size block chunks
|
FILTER_CHUNK_SIZE = 100_000 # split filter generation tasks into this size block chunks
|
||||||
FILTER_FLUSH_SIZE = 10_000 # flush to db after processing this many filters and update progress
|
FILTER_FLUSH_SIZE = 10_000 # flush to db after processing this many filters and update progress
|
||||||
CLAIM_CHUNK_SIZE = 50_000 # split claim sync tasks into this size block chunks
|
CLAIM_CHUNK_SIZE = 50_000 # split claim sync tasks into this size block chunks
|
||||||
|
@ -48,6 +48,7 @@ class BlockchainSync(Sync):
|
||||||
self.advance_loop_event = asyncio.Event()
|
self.advance_loop_event = asyncio.Event()
|
||||||
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
|
self.db.stop_event.clear()
|
||||||
self.advance_loop_task = asyncio.create_task(self.advance())
|
self.advance_loop_task = asyncio.create_task(self.advance())
|
||||||
await self.advance_loop_task
|
await self.advance_loop_task
|
||||||
self.chain.subscribe()
|
self.chain.subscribe()
|
||||||
|
|
|
@ -374,11 +374,17 @@ class Advanced(Basic):
|
||||||
#self.get_or_create_bar("read", "├─ blocks read", "blocks", d['blocks'], True)
|
#self.get_or_create_bar("read", "├─ blocks read", "blocks", d['blocks'], True)
|
||||||
#self.get_or_create_bar("save", "└─┬ txs saved", "txs", d['txs'], True)
|
#self.get_or_create_bar("save", "└─┬ txs saved", "txs", d['txs'], True)
|
||||||
else:
|
else:
|
||||||
base_name = name[:name.rindex('.')]
|
if d['done'] == (-1,)*len(d['done']):
|
||||||
for child_name, child_bar in self.bars.items():
|
base_name = name[:name.rindex('.')]
|
||||||
if child_name.startswith(base_name):
|
for child_name, child_bar in self.bars.items():
|
||||||
child_bar.close()
|
if child_name.startswith(base_name):
|
||||||
bar.close()
|
child_bar.close()
|
||||||
|
bar.close()
|
||||||
|
else:
|
||||||
|
if len(d['done']) > 1:
|
||||||
|
bar.update(d['done'])
|
||||||
|
else:
|
||||||
|
bar.update(d['done'][0])
|
||||||
|
|
||||||
def sync_task(self, name, d):
|
def sync_task(self, name, d):
|
||||||
bar_name = f"{name}#{d['id']}"
|
bar_name = f"{name}#{d['id']}"
|
||||||
|
|
|
@ -624,7 +624,7 @@ class BulkLoader:
|
||||||
d['expiration_height'] = expiration_height
|
d['expiration_height'] = expiration_height
|
||||||
d['takeover_height'] = takeover_height
|
d['takeover_height'] = takeover_height
|
||||||
d['is_controlling'] = takeover_height is not None
|
d['is_controlling'] = takeover_height is not None
|
||||||
if d['is_signature_valid']:
|
if d['is_signature_valid'] and channel_url is not None:
|
||||||
d['canonical_url'] = channel_url + '/' + short_url
|
d['canonical_url'] = channel_url + '/' + short_url
|
||||||
else:
|
else:
|
||||||
d['canonical_url'] = None
|
d['canonical_url'] = None
|
||||||
|
|
|
@ -741,6 +741,23 @@ class TestGeneralBlockchainSync(SyncingBlockchainTestCase):
|
||||||
empty_name, = await self.db.search_claims()
|
empty_name, = await self.db.search_claims()
|
||||||
self.assertEqual('', empty_name.normalized_name)
|
self.assertEqual('', empty_name.normalized_name)
|
||||||
|
|
||||||
|
async def test_claim_in_abandoned_channel(self):
|
||||||
|
await self.sync.stop()
|
||||||
|
channel_1 = await self.get_claim(await self.create_claim(is_channel=True))
|
||||||
|
channel_2 = await self.get_claim(await self.create_claim(is_channel=True))
|
||||||
|
await self.generate(1, wait=False)
|
||||||
|
await self.create_claim(sign=channel_1)
|
||||||
|
await self.create_claim(sign=channel_2)
|
||||||
|
await self.generate(1, wait=False)
|
||||||
|
await self.abandon_claim(channel_1.tx_ref.id)
|
||||||
|
await self.generate(1, wait=False)
|
||||||
|
await self.sync.start()
|
||||||
|
c1, c2 = await self.db.search_claims(claim_type='stream')
|
||||||
|
self.assertEqual(c1.meta['is_signature_valid'], True) # valid at time of pubulish
|
||||||
|
self.assertIsNone(c1.meta['canonical_url'], None) # channel is abandoned
|
||||||
|
self.assertEqual(c2.meta['is_signature_valid'], True)
|
||||||
|
self.assertIsNotNone(c2.meta['canonical_url'])
|
||||||
|
|
||||||
async def test_short_and_canonical_urls(self):
|
async def test_short_and_canonical_urls(self):
|
||||||
search = self.db.search_claims
|
search = self.db.search_claims
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue