From 81a3ad3a0da4ef6a3171966d4ac2baf918902c24 Mon Sep 17 00:00:00 2001 From: Jane Lusby Date: Tue, 8 Sep 2020 10:34:51 -0700 Subject: [PATCH] filter inventory advertisements correctly --- zebra-network/src/peer/handshake.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/zebra-network/src/peer/handshake.rs b/zebra-network/src/peer/handshake.rs index d6e184e6..caa111fa 100644 --- a/zebra-network/src/peer/handshake.rs +++ b/zebra-network/src/peer/handshake.rs @@ -401,9 +401,24 @@ where // query rather than a newly gossiped block. // // https://zebra.zfnd.org/dev/rfcs/0003-inventory-tracking.html#inventory-monitoring - if hashes.len() == 1 { - let hash = hashes[0]; - let _ = inv_collector.send((hash, addr)); + match hashes.as_slice() { + [hash @ InventoryHash::Block(_)] => { + let _ = inv_collector.send((*hash, addr)); + } + [hashes @ ..] + if hashes + .iter() + .any(|&hash| matches!(hash, InventoryHash::Tx(_))) => + { + for hash in hashes { + if matches!(hash, InventoryHash::Tx(_)) { + let _ = inv_collector.send((*hash, addr)); + } else { + debug!(?hash, "ignored non Tx inventory hash") + } + } + } + ignored => debug!(?ignored, "ignored inventory advert"), } } msg