a support create and abandon in same block no longer inserts support

This commit is contained in:
Lex Berezhny 2019-12-14 17:49:39 -05:00
parent 7fa26d59da
commit 08792e794f
2 changed files with 15 additions and 0 deletions

View file

@ -739,6 +739,13 @@ class SQLDB:
insert_claims.remove(new_claim) insert_claims.remove(new_claim)
skip_insert_claim_timer.stop() 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 = timer.add_timer('recording expired claims')
expire_timer.start() expire_timer.start()
for expired in self.get_expiring(height): for expired in self.get_expiring(height):

View file

@ -342,6 +342,14 @@ class TestClaimtrie(TestSQLDB):
advance(10, [stream, update, self.get_abandon(update)]) advance(10, [stream, update, self.get_abandon(update)])
self.assertFalse(reader._search()) 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 @staticmethod
def _get_x_with_claim_id_prefix(getter, prefix, cached_iteration=None, **kwargs): def _get_x_with_claim_id_prefix(getter, prefix, cached_iteration=None, **kwargs):
iterations = cached_iteration+1 if cached_iteration else 100 iterations = cached_iteration+1 if cached_iteration else 100