diff --git a/lbry/lbry/wallet/server/db/writer.py b/lbry/lbry/wallet/server/db/writer.py index d795f5eff..fc83cd318 100644 --- a/lbry/lbry/wallet/server/db/writer.py +++ b/lbry/lbry/wallet/server/db/writer.py @@ -718,8 +718,6 @@ class SQLDB: claim_hash = output.claim_hash update_claims.append(output) recalculate_claim_hashes.add(claim_hash) - delete_claim_hashes.discard(claim_hash) - update_claim_hashes.add(claim_hash) body_timer.stop() skip_update_claim_timer = timer.add_timer('skip update of abandoned claims') @@ -727,8 +725,10 @@ class SQLDB: for updated_claim in list(update_claims): if updated_claim.ref.hash in delete_others: update_claims.remove(updated_claim) - delete_claim_hashes.add(updated_claim.claim_hash) - update_claim_hashes.discard(updated_claim.claim_hash) + for updated_claim in update_claims: + claim_hash = updated_claim.claim_hash + delete_claim_hashes.discard(claim_hash) + update_claim_hashes.add(claim_hash) skip_update_claim_timer.stop() skip_insert_claim_timer = timer.add_timer('skip insertion of abandoned claims') diff --git a/lbry/tests/unit/wallet/server/test_sqldb.py b/lbry/tests/unit/wallet/server/test_sqldb.py index 03ffcc033..c5f3f29c3 100644 --- a/lbry/tests/unit/wallet/server/test_sqldb.py +++ b/lbry/tests/unit/wallet/server/test_sqldb.py @@ -321,6 +321,14 @@ class TestClaimtrie(TestSQLDB): advance(10, [stream, self.get_stream_update(stream, 11*COIN)]) self.assertTrue(reader._search()) + def test_double_updates_in_same_block(self): + advance, state = self.advance, self.state + stream = self.get_stream('Claim A', 10*COIN) + advance(10, [stream]) + update = self.get_stream_update(stream, 11*COIN) + advance(20, [update, self.get_stream_update(update, 9*COIN)]) + self.assertTrue(reader._search()) + def test_create_and_abandon_in_same_block(self): advance, state = self.advance, self.state stream = self.get_stream('Claim A', 10*COIN)