Merge pull request #368 from mauzmorose/bip157-service-flag
bip157: Add NODE_COMPACT_FILTERS Service Flag
This commit is contained in:
commit
efd2168364
|
@ -126,6 +126,10 @@ impl ServiceFlags {
|
||||||
/// data.
|
/// data.
|
||||||
pub const WITNESS: ServiceFlags = ServiceFlags(1 << 3);
|
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
|
/// NETWORK_LIMITED means the same as NODE_NETWORK with the limitation of only serving the last
|
||||||
/// 288 (2 day) blocks.
|
/// 288 (2 day) blocks.
|
||||||
/// See BIP159 for details on how this is implemented.
|
/// See BIP159 for details on how this is implemented.
|
||||||
|
@ -197,6 +201,7 @@ impl fmt::Display for ServiceFlags {
|
||||||
write_flag!(GETUTXO);
|
write_flag!(GETUTXO);
|
||||||
write_flag!(BLOOM);
|
write_flag!(BLOOM);
|
||||||
write_flag!(WITNESS);
|
write_flag!(WITNESS);
|
||||||
|
write_flag!(COMPACT_FILTERS);
|
||||||
write_flag!(NETWORK_LIMITED);
|
write_flag!(NETWORK_LIMITED);
|
||||||
// If there are unknown flags left, we append them in hex.
|
// If there are unknown flags left, we append them in hex.
|
||||||
if flags != ServiceFlags::NONE {
|
if flags != ServiceFlags::NONE {
|
||||||
|
@ -319,6 +324,7 @@ mod tests {
|
||||||
ServiceFlags::GETUTXO,
|
ServiceFlags::GETUTXO,
|
||||||
ServiceFlags::BLOOM,
|
ServiceFlags::BLOOM,
|
||||||
ServiceFlags::WITNESS,
|
ServiceFlags::WITNESS,
|
||||||
|
ServiceFlags::COMPACT_FILTERS,
|
||||||
ServiceFlags::NETWORK_LIMITED,
|
ServiceFlags::NETWORK_LIMITED,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -338,13 +344,17 @@ mod tests {
|
||||||
flags2 ^= ServiceFlags::WITNESS;
|
flags2 ^= ServiceFlags::WITNESS;
|
||||||
assert_eq!(flags2, ServiceFlags::GETUTXO);
|
assert_eq!(flags2, ServiceFlags::GETUTXO);
|
||||||
|
|
||||||
|
flags2 |= ServiceFlags::COMPACT_FILTERS;
|
||||||
|
flags2 ^= ServiceFlags::GETUTXO;
|
||||||
|
assert_eq!(flags2, ServiceFlags::COMPACT_FILTERS);
|
||||||
|
|
||||||
// Test formatting.
|
// Test formatting.
|
||||||
assert_eq!("ServiceFlags(NONE)", ServiceFlags::NONE.to_string());
|
assert_eq!("ServiceFlags(NONE)", ServiceFlags::NONE.to_string());
|
||||||
assert_eq!("ServiceFlags(WITNESS)", ServiceFlags::WITNESS.to_string());
|
assert_eq!("ServiceFlags(WITNESS)", ServiceFlags::WITNESS.to_string());
|
||||||
let flag = ServiceFlags::WITNESS | ServiceFlags::BLOOM | ServiceFlags::NETWORK;
|
let flag = ServiceFlags::WITNESS | ServiceFlags::BLOOM | ServiceFlags::NETWORK;
|
||||||
assert_eq!("ServiceFlags(NETWORK|BLOOM|WITNESS)", flag.to_string());
|
assert_eq!("ServiceFlags(NETWORK|BLOOM|WITNESS)", flag.to_string());
|
||||||
let flag = ServiceFlags::WITNESS | 0xf0.into();
|
let flag = ServiceFlags::WITNESS | 0xf0.into();
|
||||||
assert_eq!("ServiceFlags(WITNESS|0xf0)", flag.to_string());
|
assert_eq!("ServiceFlags(WITNESS|COMPACT_FILTERS|0xb0)", flag.to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue