mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-03 20:35:17 +02:00
Merge #19044: net processing: Add support for getcfilters
9e36067d8c[test] Add test for cfilters. (Jim Posen)11106a4722[net processing] Message handling for getcfilters. (Jim Posen)e535670726[indexes] Fix default [de]serialization of BlockFilter. (Jim Posen)bb911ae7f5[refactor] Pass CNode and CConnman by reference (John Newbery) Pull request description: Support `getcfilters` requests when `-peerblockfilters` is set. Does not advertise compact filter support in version messages. ACKs for top commit: Empact: re-Code Review ACK9e36067d8cMarcoFalke: re-ACK9e36067d8c, only change is adding commit "[refactor] Pass CNode and CConnman by reference" 🥑 jkczyz: ACK9e36067d8cfjahr: Code review ACK9e36067d8cTree-SHA512: b45b42a25905ef0bd9e195029185300c86856c87f78cbe17921f4a25e159ae0f6f003e61714fa43779017eb97cd89d3568419be88e47d19dc8095562939e7887
This commit is contained in:
@@ -1516,6 +1516,57 @@ class msg_no_witness_blocktxn(msg_blocktxn):
|
||||
def serialize(self):
|
||||
return self.block_transactions.serialize(with_witness=False)
|
||||
|
||||
|
||||
class msg_getcfilters:
|
||||
__slots__ = ("filter_type", "start_height", "stop_hash")
|
||||
msgtype = b"getcfilters"
|
||||
|
||||
def __init__(self, filter_type, start_height, stop_hash):
|
||||
self.filter_type = filter_type
|
||||
self.start_height = start_height
|
||||
self.stop_hash = stop_hash
|
||||
|
||||
def deserialize(self, f):
|
||||
self.filter_type = struct.unpack("<B", f.read(1))[0]
|
||||
self.start_height = struct.unpack("<I", f.read(4))[0]
|
||||
self.stop_hash = deser_uint256(f)
|
||||
|
||||
def serialize(self):
|
||||
r = b""
|
||||
r += struct.pack("<B", self.filter_type)
|
||||
r += struct.pack("<I", self.start_height)
|
||||
r += ser_uint256(self.stop_hash)
|
||||
return r
|
||||
|
||||
def __repr__(self):
|
||||
return "msg_getcfilters(filter_type={:#x}, start_height={}, stop_hash={:x})".format(
|
||||
self.filter_type, self.start_height, self.stop_hash)
|
||||
|
||||
class msg_cfilter:
|
||||
__slots__ = ("filter_type", "block_hash", "filter_data")
|
||||
msgtype = b"cfilter"
|
||||
|
||||
def __init__(self, filter_type=None, block_hash=None, filter_data=None):
|
||||
self.filter_type = filter_type
|
||||
self.block_hash = block_hash
|
||||
self.filter_data = filter_data
|
||||
|
||||
def deserialize(self, f):
|
||||
self.filter_type = struct.unpack("<B", f.read(1))[0]
|
||||
self.block_hash = deser_uint256(f)
|
||||
self.filter_data = deser_string(f)
|
||||
|
||||
def serialize(self):
|
||||
r = b""
|
||||
r += struct.pack("<B", self.filter_type)
|
||||
r += ser_uint256(self.block_hash)
|
||||
r += ser_string(self.filter_data)
|
||||
return r
|
||||
|
||||
def __repr__(self):
|
||||
return "msg_cfilter(filter_type={:#x}, block_hash={:x})".format(
|
||||
self.filter_type, self.block_hash)
|
||||
|
||||
class msg_getcfheaders:
|
||||
__slots__ = ("filter_type", "start_height", "stop_hash")
|
||||
msgtype = b"getcfheaders"
|
||||
|
||||
@@ -31,8 +31,9 @@ from test_framework.messages import (
|
||||
msg_block,
|
||||
MSG_BLOCK,
|
||||
msg_blocktxn,
|
||||
msg_cfheaders,
|
||||
msg_cfcheckpt,
|
||||
msg_cfheaders,
|
||||
msg_cfilter,
|
||||
msg_cmpctblock,
|
||||
msg_feefilter,
|
||||
msg_filteradd,
|
||||
@@ -69,8 +70,9 @@ MESSAGEMAP = {
|
||||
b"addr": msg_addr,
|
||||
b"block": msg_block,
|
||||
b"blocktxn": msg_blocktxn,
|
||||
b"cfheaders": msg_cfheaders,
|
||||
b"cfcheckpt": msg_cfcheckpt,
|
||||
b"cfheaders": msg_cfheaders,
|
||||
b"cfilter": msg_cfilter,
|
||||
b"cmpctblock": msg_cmpctblock,
|
||||
b"feefilter": msg_feefilter,
|
||||
b"filteradd": msg_filteradd,
|
||||
@@ -332,8 +334,9 @@ class P2PInterface(P2PConnection):
|
||||
def on_addr(self, message): pass
|
||||
def on_block(self, message): pass
|
||||
def on_blocktxn(self, message): pass
|
||||
def on_cfheaders(self, message): pass
|
||||
def on_cfcheckpt(self, message): pass
|
||||
def on_cfheaders(self, message): pass
|
||||
def on_cfilter(self, message): pass
|
||||
def on_cmpctblock(self, message): pass
|
||||
def on_feefilter(self, message): pass
|
||||
def on_filteradd(self, message): pass
|
||||
|
||||
Reference in New Issue
Block a user