net_utils_base: fix peer list parsing

Fields are written with their "name" as key, and that name changed.
This commit is contained in:
moneromooo-monero 2017-12-08 18:26:36 +00:00
parent fe5ab2c439
commit 27aa8ce95b
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 25 additions and 3 deletions

View File

@ -166,15 +166,37 @@ namespace net_utils
BEGIN_KV_SERIALIZE_MAP() BEGIN_KV_SERIALIZE_MAP()
uint8_t type = is_store ? this_ref.get_type_id() : 0; uint8_t type = is_store ? this_ref.get_type_id() : 0;
epee::serialization::selector<is_store>::serialize(type, stg, hparent_section, "type"); if (!epee::serialization::selector<is_store>::serialize(type, stg, hparent_section, "type"))
return false;
switch (type) switch (type)
{ {
case ipv4_network_address::ID: case ipv4_network_address::ID:
{
if (!is_store) if (!is_store)
{
const_cast<network_address&>(this_ref) = ipv4_network_address{0, 0}; const_cast<network_address&>(this_ref) = ipv4_network_address{0, 0};
KV_SERIALIZE(template as_mutable<ipv4_network_address>()); auto &addr = this_ref.template as_mutable<ipv4_network_address>();
if (epee::serialization::selector<is_store>::serialize(addr, stg, hparent_section, "addr"))
MDEBUG("Found as addr: " << this_ref.str());
else if (epee::serialization::selector<is_store>::serialize(addr, stg, hparent_section, "template as<ipv4_network_address>()"))
MDEBUG("Found as template as<ipv4_network_address>(): " << this_ref.str());
else if (epee::serialization::selector<is_store>::serialize(addr, stg, hparent_section, "template as_mutable<ipv4_network_address>()"))
MDEBUG("Found as template as_mutable<ipv4_network_address>(): " << this_ref.str());
else
{
MWARNING("Address not found");
return false;
}
}
else
{
auto &addr = this_ref.template as_mutable<ipv4_network_address>();
if (!epee::serialization::selector<is_store>::serialize(addr, stg, hparent_section, "addr"))
return false;
}
break; break;
default: MERROR("Unsupported network address type: " << type); return false; }
default: MERROR("Unsupported network address type: " << (unsigned)type); return false;
} }
END_KV_SERIALIZE_MAP() END_KV_SERIALIZE_MAP()
}; };