This commit is contained in:
+2
-2
@@ -172,8 +172,8 @@ namespace crypto {
|
||||
*/
|
||||
template<typename T>
|
||||
T rand() {
|
||||
static_assert(std::is_standard_layout_v<T>, "cannot write random bytes into non-standard layout type");
|
||||
static_assert(std::is_trivially_copyable_v<T>, "cannot write random bytes into non-trivially copyable type");
|
||||
static_assert(std::is_standard_layout<T>(), "cannot write random bytes into non-standard layout type");
|
||||
static_assert(std::is_trivially_copyable<T>(), "cannot write random bytes into non-trivially copyable type");
|
||||
typename std::remove_cv<T>::type res;
|
||||
generate_random_bytes_thread_safe(sizeof(T), (uint8_t*)&res);
|
||||
return res;
|
||||
|
||||
@@ -40,15 +40,6 @@
|
||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||
#define MONERO_DEFAULT_LOG_CATEGORY "cn.block_queue"
|
||||
|
||||
namespace std {
|
||||
static_assert(sizeof(size_t) <= sizeof(boost::uuids::uuid), "boost::uuids::uuid too small");
|
||||
template<> struct hash<boost::uuids::uuid> {
|
||||
std::size_t operator()(const boost::uuids::uuid &_v) const {
|
||||
return reinterpret_cast<const std::size_t &>(_v);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
|
||||
@@ -472,7 +463,7 @@ bool block_queue::has_spans(const boost::uuids::uuid &connection_id) const
|
||||
float block_queue::get_speed(const boost::uuids::uuid &connection_id) const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unordered_map<boost::uuids::uuid, float> speeds;
|
||||
std::unordered_map<boost::uuids::uuid, float, boost::hash<boost::uuids::uuid>> speeds;
|
||||
for (const auto &span: blocks)
|
||||
{
|
||||
if (span.blocks.empty())
|
||||
@@ -480,7 +471,7 @@ float block_queue::get_speed(const boost::uuids::uuid &connection_id) const
|
||||
// note that the average below does not average over the whole set, but over the
|
||||
// previous pseudo average and the latest rate: this gives much more importance
|
||||
// to the latest measurements, which is fine here
|
||||
std::unordered_map<boost::uuids::uuid, float>::iterator i = speeds.find(span.connection_id);
|
||||
const auto i = speeds.find(span.connection_id);
|
||||
if (i == speeds.end())
|
||||
speeds.insert(std::make_pair(span.connection_id, span.rate));
|
||||
else
|
||||
|
||||
+4
-4
@@ -141,9 +141,9 @@ void print_genesis_tx_hex(const cryptonote::network_type nettype) {
|
||||
miner_key_file << "Miner account address:" << std::endl;
|
||||
miner_key_file << cryptonote::get_account_address_as_str((network_type)nettype, false, miner_acc1.get_keys().m_account_address);
|
||||
miner_key_file << std::endl<< "Miner spend secret key:" << std::endl;
|
||||
epee::to_hex::formatted(miner_key_file, epee::as_byte_span(miner_acc1.get_keys().m_spend_secret_key));
|
||||
epee::to_hex::formatted(miner_key_file, epee::as_byte_span(unwrap(unwrap(miner_acc1.get_keys().m_spend_secret_key))));
|
||||
miner_key_file << std::endl << "Miner view secret key:" << std::endl;
|
||||
epee::to_hex::formatted(miner_key_file, epee::as_byte_span(miner_acc1.get_keys().m_view_secret_key));
|
||||
epee::to_hex::formatted(miner_key_file, epee::as_byte_span(unwrap(unwrap(miner_acc1.get_keys().m_view_secret_key))));
|
||||
miner_key_file << std::endl << std::endl;
|
||||
miner_key_file.close();
|
||||
|
||||
@@ -157,9 +157,9 @@ void print_genesis_tx_hex(const cryptonote::network_type nettype) {
|
||||
std::cout << "Miner account address:" << std::endl;
|
||||
std::cout << cryptonote::get_account_address_as_str((network_type)nettype, false, miner_acc1.get_keys().m_account_address);
|
||||
std::cout << std::endl << "Miner spend secret key:" << std::endl;
|
||||
epee::to_hex::formatted(std::cout, epee::as_byte_span(miner_acc1.get_keys().m_spend_secret_key));
|
||||
epee::to_hex::formatted(std::cout, epee::as_byte_span(unwrap(unwrap(miner_acc1.get_keys().m_spend_secret_key))));
|
||||
std::cout << std::endl << "Miner view secret key:" << std::endl;
|
||||
epee::to_hex::formatted(std::cout, epee::as_byte_span(miner_acc1.get_keys().m_view_secret_key));
|
||||
epee::to_hex::formatted(std::cout, epee::as_byte_span(unwrap(unwrap(miner_acc1.get_keys().m_view_secret_key))));
|
||||
std::cout << std::endl << std::endl;
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
+2
-2
@@ -127,7 +127,7 @@ namespace lmdb
|
||||
/*!
|
||||
A LMDB comparison function that uses `std::memcmp`.
|
||||
|
||||
\toaram T is `!epee::has_padding`
|
||||
\toaram T has standard layout and an alignment of 1
|
||||
\tparam offset to `T` within the value.
|
||||
|
||||
\return The result of `std::memcmp` over the value.
|
||||
@@ -135,7 +135,7 @@ namespace lmdb
|
||||
template<typename T, std::size_t offset = 0>
|
||||
inline int compare(MDB_val const* left, MDB_val const* right) noexcept
|
||||
{
|
||||
static_assert(!epee::has_padding<T>(), "memcmp will not work");
|
||||
static_assert(std::is_standard_layout<T>() && alignof(T) == 1, "memcmp will not work");
|
||||
if (!left || !right || left->mv_size < sizeof(T) + offset || right->mv_size < sizeof(T) + offset)
|
||||
{
|
||||
assert("invalid use of custom comparison" == 0);
|
||||
|
||||
@@ -8915,9 +8915,9 @@ bool simple_wallet::submit_transfer(const std::vector<std::string> &args_)
|
||||
std::string get_tx_key_stream(crypto::secret_key tx_key, std::vector<crypto::secret_key> additional_tx_keys)
|
||||
{
|
||||
ostringstream oss;
|
||||
oss << epee::string_tools::pod_to_hex(tx_key);
|
||||
oss << epee::string_tools::pod_to_hex(unwrap(unwrap(tx_key)));
|
||||
for (size_t i = 0; i < additional_tx_keys.size(); ++i)
|
||||
oss << epee::string_tools::pod_to_hex(additional_tx_keys[i]);
|
||||
oss << epee::string_tools::pod_to_hex(unwrap(unwrap(additional_tx_keys[i])));
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
||||
@@ -852,7 +852,7 @@ std::string WalletImpl::integratedAddress(const std::string &payment_id) const
|
||||
|
||||
std::string WalletImpl::secretViewKey() const
|
||||
{
|
||||
return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key);
|
||||
return epee::string_tools::pod_to_hex(unwrap(unwrap(m_wallet->get_account().get_keys().m_view_secret_key)));
|
||||
}
|
||||
|
||||
std::string WalletImpl::publicViewKey() const
|
||||
@@ -862,7 +862,7 @@ std::string WalletImpl::publicViewKey() const
|
||||
|
||||
std::string WalletImpl::secretSpendKey() const
|
||||
{
|
||||
return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_spend_secret_key);
|
||||
return epee::string_tools::pod_to_hex(unwrap(unwrap(m_wallet->get_account().get_keys().m_spend_secret_key)));
|
||||
}
|
||||
|
||||
std::string WalletImpl::publicSpendKey() const
|
||||
@@ -1886,9 +1886,9 @@ std::string WalletImpl::getTxKey(const std::string &txid_str) const
|
||||
{
|
||||
clearStatus();
|
||||
std::ostringstream oss;
|
||||
oss << epee::string_tools::pod_to_hex(tx_key);
|
||||
oss << epee::string_tools::pod_to_hex(unwrap(unwrap(tx_key)));
|
||||
for (size_t i = 0; i < additional_tx_keys.size(); ++i)
|
||||
oss << epee::string_tools::pod_to_hex(additional_tx_keys[i]);
|
||||
oss << epee::string_tools::pod_to_hex(unwrap(unwrap(additional_tx_keys[i])));
|
||||
return oss.str();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -5124,7 +5124,7 @@ boost::optional<wallet2::keys_file_data> wallet2::get_keys_file_data(const epee:
|
||||
original_address = get_account_address_as_str(m_nettype, false, m_original_address);
|
||||
value.SetString(original_address.c_str(), original_address.length());
|
||||
json.AddMember("original_address", value, json.GetAllocator());
|
||||
original_view_secret_key = epee::string_tools::pod_to_hex(m_original_view_secret_key);
|
||||
original_view_secret_key = epee::string_tools::pod_to_hex(unwrap(unwrap(m_original_view_secret_key)));
|
||||
value.SetString(original_view_secret_key.c_str(), original_view_secret_key.length());
|
||||
json.AddMember("original_view_secret_key", value, json.GetAllocator());
|
||||
}
|
||||
|
||||
@@ -1346,9 +1346,9 @@ namespace tools
|
||||
res.tx_hash_list.push_back(epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(ptx.tx)));
|
||||
if (req.get_tx_keys)
|
||||
{
|
||||
res.tx_key_list.push_back(epee::string_tools::pod_to_hex(ptx.tx_key));
|
||||
res.tx_key_list.push_back(epee::string_tools::pod_to_hex(unwrap(unwrap(ptx.tx_key))));
|
||||
for (const crypto::secret_key& additional_tx_key : ptx.additional_tx_keys)
|
||||
res.tx_key_list.back() += epee::string_tools::pod_to_hex(additional_tx_key);
|
||||
res.tx_key_list.back() += epee::string_tools::pod_to_hex(unwrap(unwrap(additional_tx_key)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user