peerstate: ignore invalid fingerprints in SQL

Normally NULL is used when there is no fingerprint, but default value
for fingerprint columns is an empty string.

In this case, loading should not fail with an "invalid length" error,
but treat the fingerprint as missing.

Strict check was introduced in commit ca95f25639
This commit is contained in:
Alexander Krotov
2020-08-05 00:00:00 +03:00
committed by link2xt
parent 03a4115a52
commit dc4fa1de65

View File

@@ -186,15 +186,18 @@ impl<'a> Peerstate<'a> {
res.public_key_fingerprint = row
.get::<_, Option<String>>(7)?
.map(|s| s.parse::<Fingerprint>())
.transpose()?;
.transpose()
.unwrap_or_default();
res.gossip_key_fingerprint = row
.get::<_, Option<String>>(8)?
.map(|s| s.parse::<Fingerprint>())
.transpose()?;
.transpose()
.unwrap_or_default();
res.verified_key_fingerprint = row
.get::<_, Option<String>>(10)?
.map(|s| s.parse::<Fingerprint>())
.transpose()?;
.transpose()
.unwrap_or_default();
res.public_key = row
.get(4)
.ok()