Test if the filter contains an element elem may be a COutPoint or bytes
(self, elem)
| 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 |