From 08792e794f2b9c12637346def7a2026ceef98178 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Sat, 14 Dec 2019 17:49:39 -0500 Subject: [PATCH] a support create and abandon in same block no longer inserts support --- lbry/lbry/wallet/server/db/writer.py | 7 +++++++ lbry/tests/unit/wallet/server/test_sqldb.py | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/lbry/lbry/wallet/server/db/writer.py b/lbry/lbry/wallet/server/db/writer.py index 8de9679cd..d795f5eff 100644 --- a/lbry/lbry/wallet/server/db/writer.py +++ b/lbry/lbry/wallet/server/db/writer.py @@ -739,6 +739,13 @@ class SQLDB: insert_claims.remove(new_claim) skip_insert_claim_timer.stop() + skip_insert_support_timer = timer.add_timer('skip insertion of abandoned supports') + skip_insert_support_timer.start() + for new_support in list(insert_supports): + if new_support.ref.hash in delete_others: + insert_supports.remove(new_support) + skip_insert_support_timer.stop() + expire_timer = timer.add_timer('recording expired claims') expire_timer.start() for expired in self.get_expiring(height): diff --git a/lbry/tests/unit/wallet/server/test_sqldb.py b/lbry/tests/unit/wallet/server/test_sqldb.py index 38a460c58..03ffcc033 100644 --- a/lbry/tests/unit/wallet/server/test_sqldb.py +++ b/lbry/tests/unit/wallet/server/test_sqldb.py @@ -342,6 +342,14 @@ class TestClaimtrie(TestSQLDB): advance(10, [stream, update, self.get_abandon(update)]) self.assertFalse(reader._search()) + def test_support_added_and_removed_in_same_block(self): + advance, state = self.advance, self.state + stream = self.get_stream('Claim A', 10*COIN) + advance(10, [stream]) + support = self.get_support(stream, COIN) + advance(20, [support, self.get_abandon(support)]) + self.assertEqual(reader._search()[0]['support_amount'], 0) + @staticmethod def _get_x_with_claim_id_prefix(getter, prefix, cached_iteration=None, **kwargs): iterations = cached_iteration+1 if cached_iteration else 100