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

Method insert

bitcoin/bloom.py:120–134  ·  view source on GitHub ↗

Insert an element in the filter. elem may be a COutPoint or bytes

(self, elem)

Source from the content-addressed store, hash-verified

118 __bit_mask = bytearray([0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80])
119
120 def insert(self, elem):
121 """Insert an element in the filter.
122
123 elem may be a COutPoint or bytes
124 """
125 if isinstance(elem, bitcoin.core.COutPoint):
126 elem = elem.serialize()
127
128 if len(self.vData) == 1 and self.vData[0] == 0xff:
129 return
130
131 for i in range(0, self.nHashFuncs):
132 nIndex = self.bloom_hash(i, elem)
133 # Sets bit nIndex of vData
134 self.vData[nIndex >> 3] |= self.__bit_mask[7 & nIndex]
135
136 def contains(self, elem):
137 """Test if the filter contains an element

Callers 4

_EvalScriptFunction · 0.80
TMethod · 0.80
conf.pyFile · 0.80

Calls 2

bloom_hashMethod · 0.95
serializeMethod · 0.45

Tested by 2

TMethod · 0.64