Skip to content

Commit 50cdc84

Browse files
committed
fix: don't return invalid values with empty MnNetInfo
If `MnNetInfo` is empty, we should be returning nothing instead of returning a CService's blank data. That behavior is reserved only for `GetPrimary()`.
1 parent 893b46a commit 50cdc84

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/evo/netinfo.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,18 @@ NetInfoStatus MnNetInfo::Validate() const
244244

245245
UniValue MnNetInfo::ToJson() const
246246
{
247+
if (IsEmpty()) {
248+
return UniValue{UniValue::VARR};
249+
}
247250
return ArrFromService(GetPrimary());
248251
}
249252

250253
std::string MnNetInfo::ToString() const
251254
{
252-
// Extra padding to account for padding done by the calling function.
253-
return strprintf("MnNetInfo()\n"
254-
" %s\n",
255-
m_addr.ToString());
255+
std::string ret{"MnNetInfo()\n"};
256+
if (!IsEmpty()) {
257+
// Extra padding to account for padding done by the calling function.
258+
ret += strprintf(" %s\n", m_addr.ToString());
259+
}
260+
return ret;
256261
}

0 commit comments

Comments
 (0)