diff --git a/lbry/schema/result.py b/lbry/schema/result.py index 6c9bc8068..9ecca5888 100644 --- a/lbry/schema/result.py +++ b/lbry/schema/result.py @@ -52,10 +52,8 @@ class Censor: if was_censored: self.total += 1 if not was_censored and self.limit_claims_per_channel is not None and row['channel_hash']: - if row['channel_hash'] not in self.claims_in_channel: - self.claims_in_channel[row['channel_hash']] = 1 - else: - self.claims_in_channel[row['channel_hash']] += 1 + self.claims_in_channel.setdefault(row['channel_hash'], 0) + self.claims_in_channel[row['channel_hash']] += 1 if self.claims_in_channel[row['channel_hash']] > self.limit_claims_per_channel: return True return was_censored diff --git a/tests/integration/blockchain/test_claim_commands.py b/tests/integration/blockchain/test_claim_commands.py index 424770408..eb239978a 100644 --- a/tests/integration/blockchain/test_claim_commands.py +++ b/tests/integration/blockchain/test_claim_commands.py @@ -319,7 +319,7 @@ class ClaimSearchCommand(ClaimTestCase): not_channel_ids=[chan2_id], has_channel_signature=True, valid_channel_signature=True) await match([], not_channel_ids=[chan1_id, chan2_id], has_channel_signature=True, valid_channel_signature=True) - async def test_limit_channel_results(self): + async def test_limit_claims_per_channel(self): match = self.assertFindsClaims chan1_id = self.get_claim_id(await self.channel_create('@chan1')) chan2_id = self.get_claim_id(await self.channel_create('@chan2'))