MCPcopy
hub / github.com/petertodd/python-bitcoinlib / contains

Method contains

bitcoin/bloom.py:136–151  ·  view source on GitHub ↗

Test if the filter contains an element elem may be a COutPoint or bytes

(self, elem)

Source from the content-addressed store, hash-verified

134 self.vData[nIndex >> 3] |= self.__bit_mask[7 & nIndex]
135
136 def contains(self, elem):
137 """Test if the filter contains an element
138
139 elem may be a COutPoint or bytes
140 """
141 if isinstance(elem, bitcoin.core.COutPoint):
142 elem = elem.serialize()
143
144 if len(self.vData) == 1 and self.vData[0] == 0xff:
145 return True
146
147 for i in range(0, self.nHashFuncs):
148 nIndex = self.bloom_hash(i, elem)
149 if not (self.vData[nIndex >> 3] & self.__bit_mask[7 & nIndex]):
150 return False
151 return True
152
153 def IsWithinSizeConstraints(self):
154 return len(self.vData) <= self.MAX_BLOOM_FILTER_SIZE and self.nHashFuncs <= self.MAX_HASH_FUNCS

Callers 3

TMethod · 0.80
FMethod · 0.80

Calls 2

bloom_hashMethod · 0.95
serializeMethod · 0.45

Tested by 3

TMethod · 0.64
FMethod · 0.64