De-inline LNS methods

This commit is contained in:
Jason Rhinelander 2020-12-06 23:09:35 -04:00
parent 4f9f39c6ab
commit 333a5f6cc3
3 changed files with 97 additions and 64 deletions

View File

@ -33,7 +33,8 @@ add_library(cryptonote_basic
cryptonote_format_utils.cpp
difficulty.cpp
hardfork.cpp
miner.cpp)
miner.cpp
tx_extra.cpp)
target_link_libraries(cryptonote_basic
PRIVATE

View File

@ -0,0 +1,79 @@
#include "tx_extra.h"
namespace cryptonote {
tx_extra_loki_name_system tx_extra_loki_name_system::make_buy(
lns::generic_owner const& owner,
lns::generic_owner const* backup_owner,
lns::mapping_type type,
const crypto::hash& name_hash,
const std::string& encrypted_value,
const crypto::hash& prev_txid)
{
tx_extra_loki_name_system result{};
result.fields = lns::extra_field::buy;
result.owner = owner;
if (backup_owner)
result.backup_owner = *backup_owner;
else
result.fields = lns::extra_field::buy_no_backup;
result.type = type;
result.name_hash = name_hash;
result.encrypted_value = encrypted_value;
result.prev_txid = prev_txid;
return result;
}
tx_extra_loki_name_system tx_extra_loki_name_system::make_renew(
lns::mapping_type type, crypto::hash const &name_hash, crypto::hash const &prev_txid)
{
assert(is_lokinet_type(type) && prev_txid);
tx_extra_loki_name_system result{};
result.fields = lns::extra_field::none;
result.type = type;
result.name_hash = name_hash;
result.prev_txid = prev_txid;
return result;
}
tx_extra_loki_name_system tx_extra_loki_name_system::make_update(
const lns::generic_signature& signature,
lns::mapping_type type,
const crypto::hash& name_hash,
std::string_view encrypted_value,
const lns::generic_owner* owner,
const lns::generic_owner* backup_owner,
const crypto::hash& prev_txid)
{
tx_extra_loki_name_system result{};
result.signature = signature;
result.type = type;
result.name_hash = name_hash;
result.fields |= lns::extra_field::signature;
if (encrypted_value.size())
{
result.fields |= lns::extra_field::encrypted_value;
result.encrypted_value = std::string{encrypted_value};
}
if (owner)
{
result.fields |= lns::extra_field::owner;
result.owner = *owner;
}
if (backup_owner)
{
result.fields |= lns::extra_field::backup_owner;
result.backup_owner = *backup_owner;
}
result.prev_txid = prev_txid;
return result;
}
}

View File

@ -480,71 +480,24 @@ namespace cryptonote
// and has a non-null txid set (which should point to the most recent registration or update).
bool is_renewing() const { return fields == lns::extra_field::none && prev_txid && is_lokinet_type(type); }
static tx_extra_loki_name_system make_buy(lns::generic_owner const &owner, lns::generic_owner const *backup_owner, lns::mapping_type type, crypto::hash const &name_hash, std::string const &encrypted_value, crypto::hash const &prev_txid)
{
tx_extra_loki_name_system result = {};
result.fields = lns::extra_field::buy;
result.owner = owner;
static tx_extra_loki_name_system make_buy(
lns::generic_owner const& owner,
lns::generic_owner const* backup_owner,
lns::mapping_type type,
const crypto::hash& name_hash,
const std::string& encrypted_value,
const crypto::hash& prev_txid);
if (backup_owner)
result.backup_owner = *backup_owner;
else
result.fields = lns::extra_field::buy_no_backup;
static tx_extra_loki_name_system make_renew(lns::mapping_type type, const crypto::hash& name_hash, const crypto::hash& prev_txid);
result.type = type;
result.name_hash = name_hash;
result.encrypted_value = encrypted_value;
result.prev_txid = prev_txid;
return result;
}
static tx_extra_loki_name_system make_renew(lns::mapping_type type, crypto::hash const &name_hash, crypto::hash const &prev_txid)
{
assert(is_lokinet_type(type) && prev_txid);
tx_extra_loki_name_system result{};
result.fields = lns::extra_field::none;
result.type = type;
result.name_hash = name_hash;
result.prev_txid = prev_txid;
return result;
}
static tx_extra_loki_name_system make_update(lns::generic_signature const &signature,
lns::mapping_type type,
crypto::hash const &name_hash,
std::string_view encrypted_value,
lns::generic_owner const *owner,
lns::generic_owner const *backup_owner,
crypto::hash const &prev_txid)
{
tx_extra_loki_name_system result = {};
result.signature = signature;
result.type = type;
result.name_hash = name_hash;
result.fields |= lns::extra_field::signature;
if (encrypted_value.size())
{
result.fields |= lns::extra_field::encrypted_value;
result.encrypted_value = std::string(reinterpret_cast<char const *>(encrypted_value.data()), encrypted_value.size());
}
if (owner)
{
result.fields |= lns::extra_field::owner;
result.owner = *owner;
}
if (backup_owner)
{
result.fields |= lns::extra_field::backup_owner;
result.backup_owner = *backup_owner;
}
result.prev_txid = prev_txid;
return result;
}
static tx_extra_loki_name_system make_update(
const lns::generic_signature& signature,
lns::mapping_type type,
const crypto::hash& name_hash,
std::string_view encrypted_value,
const lns::generic_owner* owner,
const lns::generic_owner* backup_owner,
const crypto::hash& prev_txid);
BEGIN_SERIALIZE()
FIELD(version)