From b40d94641d85732d3cdd6cd3d3871b00005f3859 Mon Sep 17 00:00:00 2001 From: Sofiane Baltaci Date: Sat, 21 Dec 2019 02:39:30 +0100 Subject: [PATCH] Add bip157 NODE_COMPACT_FILTERS Service Flag --- src/network/constants.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/network/constants.rs b/src/network/constants.rs index 37ba835c..bcf522b0 100644 --- a/src/network/constants.rs +++ b/src/network/constants.rs @@ -125,6 +125,10 @@ impl ServiceFlags { /// WITNESS indicates that a node can be asked for blocks and transactions including witness /// data. pub const WITNESS: ServiceFlags = ServiceFlags(1 << 3); + + /// COMPACT_FILTERS means the node will service basic block filter requests. + /// See BIP157 and BIP158 for details on how this is implemented. + pub const COMPACT_FILTERS: ServiceFlags = ServiceFlags(1 << 6); /// NETWORK_LIMITED means the same as NODE_NETWORK with the limitation of only serving the last /// 288 (2 day) blocks. @@ -319,6 +323,7 @@ mod tests { ServiceFlags::GETUTXO, ServiceFlags::BLOOM, ServiceFlags::WITNESS, + ServiceFlags::COMPACT_FILTERS, ServiceFlags::NETWORK_LIMITED, ]; @@ -337,6 +342,10 @@ mod tests { flags2 ^= ServiceFlags::WITNESS; assert_eq!(flags2, ServiceFlags::GETUTXO); + + flags2 |= ServiceFlags::COMPACT_FILTERS; + flags2 ^= ServiceFlags::GETUTXO; + assert_eq!(flags2, ServiceFlags::COMPACT_FILTERS); // Test formatting. assert_eq!("ServiceFlags(NONE)", ServiceFlags::NONE.to_string());