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