Skip to content

Commit

Permalink
dont delete claims on reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
shyba committed Feb 23, 2021
1 parent 38c3a8f commit d0e4732
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 14 deletions.
4 changes: 0 additions & 4 deletions lbry/wallet/server/block_processor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import time
import asyncio
from struct import pack, unpack
Expand Down Expand Up @@ -287,9 +286,6 @@ def flush_backup():
await self.run_in_thread_with_lock(flush_backup)
last -= len(raw_blocks)

if self.sql:
await self.run_in_thread_with_lock(self.db.sql.delete_claims_above_height, self.height)
await self.db.search_index.delete_above_height(self.height)
await self.prefetcher.reset_height(self.height)
self.reorg_count_metric.inc()
except:
Expand Down
2 changes: 1 addition & 1 deletion lbry/wallet/server/db/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def insert_claims(self, txos: List[Output], header):
claims = self._upsertable_claims(txos, header)
if claims:
self.executemany("""
INSERT OR IGNORE INTO claim (
INSERT OR REPLACE INTO claim (
claim_hash, claim_id, claim_name, normalized, txo_hash, tx_position, amount,
claim_type, media_type, stream_type, timestamp, creation_timestamp,
fee_currency, fee_amount, title, description, author, duration, height, reposted_claim_hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,6 @@ async def test_reorg_change_claim_height(self):
client_reorg_block_hash = (await self.ledger.headers.hash(208)).decode()
self.assertEqual(client_reorg_block_hash, reorg_block_hash)

# verify the dropped claim is no longer returned by claim search
txos, _, _, _ = await self.ledger.claim_search([], name='hovercraft')
self.assertListEqual(txos, [])

# verify the claim published a block earlier wasn't also reverted
txos, _, _, _ = await self.ledger.claim_search([], name='still-valid')
self.assertEqual(1, len(txos))
self.assertEqual(207, txos[0].tx_ref.height)

# broadcast the claim in a different block
new_txid = await self.blockchain.sendrawtransaction(hexlify(broadcast_tx.raw).decode())
self.assertEqual(broadcast_tx.id, new_txid)
Expand Down

0 comments on commit d0e4732

Please sign in to comment.