Add service sanitization to `MetaAddr::sanitize`

This makes sure that deserialization and generated `MetaAddr`s are consistent.
This commit is contained in:
teor 2021-05-26 15:32:05 +10:00 committed by Deirdre Connolly
parent bf6fe175dd
commit 81630d19f2
1 changed files with 2 additions and 3 deletions

View File

@ -262,9 +262,8 @@ impl MetaAddr {
let last_seen = Utc.timestamp(ts - ts.rem_euclid(interval), 0);
MetaAddr {
addr: self.addr,
// services are sanitized during parsing, or set to a fixed valued by
// new_local_listener, so we don't need to sanitize here
services: self.services,
// deserialization also sanitizes services to known flags
services: self.services & PeerServices::all(),
last_seen,
// the state isn't sent to the remote peer, but sanitize it anyway
last_connection_state: NeverAttemptedGossiped,