aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/blockchain.cpp3
-rw-r--r--src/cryptonote_core/blockchain.h1
-rw-r--r--src/cryptonote_core/cryptonote_basic_impl.cpp30
-rw-r--r--src/cryptonote_core/cryptonote_basic_impl.h14
-rw-r--r--src/cryptonote_core/cryptonote_boost_serialization.h1
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp12
-rw-r--r--src/cryptonote_core/cryptonote_format_utils.cpp33
-rw-r--r--src/cryptonote_core/miner.cpp3
-rw-r--r--src/cryptonote_core/tx_pool.cpp20
9 files changed, 80 insertions, 37 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 789687ce0..b344c5597 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -31,6 +31,7 @@
#include <algorithm>
#include <cstdio>
#include <boost/filesystem.hpp>
+#include <boost/range/adaptor/reversed.hpp>
#include "include_base_utils.h"
#include "cryptonote_basic_impl.h"
@@ -933,7 +934,7 @@ difficulty_type Blockchain::get_next_difficulty_for_alternative_chain(const std:
size_t count = 0;
size_t max_i = timestamps.size()-1;
// get difficulties and timestamps from most recent blocks in alt chain
- BOOST_REVERSE_FOREACH(auto it, alt_chain)
+ for(auto it: boost::adaptors::reverse(alt_chain))
{
timestamps[max_i - count] = it->second.bl.timestamp;
cumulative_difficulties[max_i - count] = it->second.cumulative_difficulty;
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index ca665e1d4..cd452faf4 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -36,7 +36,6 @@
#include <boost/multi_index/global_fun.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp>
-#include <boost/foreach.hpp>
#include <atomic>
#include <unordered_map>
#include <unordered_set>
diff --git a/src/cryptonote_core/cryptonote_basic_impl.cpp b/src/cryptonote_core/cryptonote_basic_impl.cpp
index 5a8c61dd9..51c9269a5 100644
--- a/src/cryptonote_core/cryptonote_basic_impl.cpp
+++ b/src/cryptonote_core/cryptonote_basic_impl.cpp
@@ -41,6 +41,7 @@ using namespace epee;
#include "common/base58.h"
#include "crypto/hash.h"
#include "common/int-util.h"
+#include "common/dns_utils.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "cn"
@@ -291,7 +292,34 @@ namespace cryptonote {
crypto::hash8 payment_id;
return get_account_integrated_address_from_str(adr, has_payment_id, payment_id, testnet, str);
}
-
+ //--------------------------------------------------------------------------------
+ bool get_account_address_from_str_or_url(
+ cryptonote::account_public_address& address
+ , bool& has_payment_id
+ , crypto::hash8& payment_id
+ , bool testnet
+ , const std::string& str_or_url
+ )
+ {
+ if (get_account_integrated_address_from_str(address, has_payment_id, payment_id, testnet, str_or_url))
+ return true;
+ bool dnssec_valid;
+ std::string address_str = tools::dns_utils::get_account_address_as_str_from_url(str_or_url, dnssec_valid);
+ return !address_str.empty() &&
+ get_account_integrated_address_from_str(address, has_payment_id, payment_id, testnet, address_str);
+ }
+ //--------------------------------------------------------------------------------
+ bool get_account_address_from_str_or_url(
+ cryptonote::account_public_address& address
+ , bool testnet
+ , const std::string& str_or_url
+ )
+ {
+ bool has_payment_id;
+ crypto::hash8 payment_id;
+ return get_account_address_from_str_or_url(address, testnet, str_or_url);
+ }
+ //--------------------------------------------------------------------------------
bool operator ==(const cryptonote::transaction& a, const cryptonote::transaction& b) {
return cryptonote::get_transaction_hash(a) == cryptonote::get_transaction_hash(b);
}
diff --git a/src/cryptonote_core/cryptonote_basic_impl.h b/src/cryptonote_core/cryptonote_basic_impl.h
index 147bc89ba..5703a7d75 100644
--- a/src/cryptonote_core/cryptonote_basic_impl.h
+++ b/src/cryptonote_core/cryptonote_basic_impl.h
@@ -100,6 +100,20 @@ namespace cryptonote {
, const std::string& str
);
+ bool get_account_address_from_str_or_url(
+ cryptonote::account_public_address& address
+ , bool& has_payment_id
+ , crypto::hash8& payment_id
+ , bool testnet
+ , const std::string& str_or_url
+ );
+
+ bool get_account_address_from_str_or_url(
+ cryptonote::account_public_address& address
+ , bool testnet
+ , const std::string& str_or_url
+ );
+
bool is_coinbase(const transaction& tx);
bool operator ==(const cryptonote::transaction& a, const cryptonote::transaction& b);
diff --git a/src/cryptonote_core/cryptonote_boost_serialization.h b/src/cryptonote_core/cryptonote_boost_serialization.h
index 7423b222a..409b9798c 100644
--- a/src/cryptonote_core/cryptonote_boost_serialization.h
+++ b/src/cryptonote_core/cryptonote_boost_serialization.h
@@ -35,7 +35,6 @@
#include <boost/serialization/variant.hpp>
#include <boost/serialization/set.hpp>
#include <boost/serialization/map.hpp>
-#include <boost/foreach.hpp>
#include <boost/serialization/is_bitwise_serializable.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/portable_binary_iarchive.hpp>
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 09184a961..900dc58ba 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -31,7 +31,6 @@
#include "include_base_utils.h"
using namespace epee;
-#include <boost/foreach.hpp>
#include <unordered_set>
#include "cryptonote_core.h"
#include "common/command_line.h"
@@ -542,6 +541,7 @@ namespace cryptonote
if (rv.outPk.size() != tx.vout.size())
{
LOG_PRINT_L1("WRONG TRANSACTION BLOB, Bad outPk size in tx " << tx_hash << ", rejected");
+ tvc.m_verifivation_failed = true;
return false;
}
for (size_t n = 0; n < tx.rct_signatures.outPk.size(); ++n)
@@ -678,7 +678,7 @@ namespace cryptonote
bool core::are_key_images_spent(const std::vector<crypto::key_image>& key_im, std::vector<bool> &spent) const
{
spent.clear();
- BOOST_FOREACH(auto& ki, key_im)
+ for(auto& ki: key_im)
{
spent.push_back(m_blockchain_storage.have_tx_keyimg_as_spent(ki));
}
@@ -691,14 +691,14 @@ namespace cryptonote
uint64_t emission_amount = 0;
uint64_t total_fee_amount = 0;
this->get_blocks(start_offset, count, blocks);
- BOOST_FOREACH(auto& b, blocks)
+ for(auto& b: blocks)
{
std::list<transaction> txs;
std::list<crypto::hash> missed_txs;
uint64_t coinbase_amount = get_outs_money_amount(b.miner_tx);
this->get_transactions(b.tx_hashes, txs, missed_txs);
uint64_t tx_fee_amount = 0;
- BOOST_FOREACH(const auto& tx, txs)
+ for(const auto& tx: txs)
{
tx_fee_amount += get_tx_fee(tx);
}
@@ -713,7 +713,7 @@ namespace cryptonote
bool core::check_tx_inputs_keyimages_diff(const transaction& tx) const
{
std::unordered_set<crypto::key_image> ki;
- BOOST_FOREACH(const auto& in, tx.vin)
+ for(const auto& in: tx.vin)
{
CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, tokey_in, false);
if(!ki.insert(tokey_in.k_image).second)
@@ -879,7 +879,7 @@ namespace cryptonote
block_to_blob(b, arg.b.block);
//pack transactions
- BOOST_FOREACH(auto& tx, txs)
+ for(auto& tx: txs)
arg.b.txs.push_back(t_serializable_object_to_blob(tx));
m_pprotocol->relay_block(arg, exclude_context);
diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp
index e04409d87..70ba7ee18 100644
--- a/src/cryptonote_core/cryptonote_format_utils.cpp
+++ b/src/cryptonote_core/cryptonote_format_utils.cpp
@@ -32,7 +32,6 @@
using namespace epee;
#include "cryptonote_format_utils.h"
-#include <boost/foreach.hpp>
#include "cryptonote_config.h"
#include "miner.h"
#include "crypto/crypto.h"
@@ -274,12 +273,12 @@ namespace cryptonote
}
uint64_t amount_in = 0;
uint64_t amount_out = 0;
- BOOST_FOREACH(auto& in, tx.vin)
+ for(auto& in: tx.vin)
{
CHECK_AND_ASSERT_MES(in.type() == typeid(txin_to_key), 0, "unexpected type id in transaction");
amount_in += boost::get<txin_to_key>(in).amount;
}
- BOOST_FOREACH(auto& o, tx.vout)
+ for(auto& o: tx.vout)
amount_out += o.amount;
CHECK_AND_ASSERT_MES(amount_in >= amount_out, false, "transaction spend (" <<amount_in << ") more than it has (" << amount_out << ")");
@@ -540,7 +539,7 @@ namespace cryptonote
uint64_t summary_inputs_money = 0;
//fill inputs
int idx = -1;
- BOOST_FOREACH(const tx_source_entry& src_entr, sources)
+ for(const tx_source_entry& src_entr: sources)
{
++idx;
if(src_entr.real_output >= src_entr.outputs.size())
@@ -574,7 +573,7 @@ namespace cryptonote
input_to_key.k_image = img;
//fill outputs array and use relative offsets
- BOOST_FOREACH(const tx_source_entry::output_entry& out_entry, src_entr.outputs)
+ for(const tx_source_entry::output_entry& out_entry: src_entr.outputs)
input_to_key.key_offsets.push_back(out_entry.first);
input_to_key.key_offsets = absolute_output_offsets_to_relative(input_to_key.key_offsets);
@@ -588,7 +587,7 @@ namespace cryptonote
uint64_t summary_outs_money = 0;
//fill outputs
size_t output_index = 0;
- BOOST_FOREACH(const tx_destination_entry& dst_entr, shuffled_dsts)
+ for(const tx_destination_entry& dst_entr: shuffled_dsts)
{
CHECK_AND_ASSERT_MES(dst_entr.amount > 0 || tx.version > 1, false, "Destination with wrong amount: " << dst_entr.amount);
crypto::key_derivation derivation;
@@ -639,13 +638,13 @@ namespace cryptonote
std::stringstream ss_ring_s;
size_t i = 0;
- BOOST_FOREACH(const tx_source_entry& src_entr, sources)
+ for(const tx_source_entry& src_entr: sources)
{
ss_ring_s << "pub_keys:" << ENDL;
std::vector<const crypto::public_key*> keys_ptrs;
std::vector<crypto::public_key> keys(src_entr.outputs.size());
size_t ii = 0;
- BOOST_FOREACH(const tx_source_entry::output_entry& o, src_entr.outputs)
+ for(const tx_source_entry::output_entry& o: src_entr.outputs)
{
keys[ii] = rct2pk(o.second.dest);
keys_ptrs.push_back(&keys[ii]);
@@ -677,7 +676,7 @@ namespace cryptonote
if (!use_simple_rct)
{
// non simple ringct requires all real inputs to be at the same index for all inputs
- BOOST_FOREACH(const tx_source_entry& src_entr, sources)
+ for(const tx_source_entry& src_entr: sources)
{
if(src_entr.real_output != sources.begin()->real_output)
{
@@ -784,7 +783,7 @@ namespace cryptonote
bool get_inputs_money_amount(const transaction& tx, uint64_t& money)
{
money = 0;
- BOOST_FOREACH(const auto& in, tx.vin)
+ for(const auto& in: tx.vin)
{
CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, tokey_in, false);
money += tokey_in.amount;
@@ -801,7 +800,7 @@ namespace cryptonote
//---------------------------------------------------------------
bool check_inputs_types_supported(const transaction& tx)
{
- BOOST_FOREACH(const auto& in, tx.vin)
+ for(const auto& in: tx.vin)
{
CHECK_AND_ASSERT_MES(in.type() == typeid(txin_to_key), false, "wrong variant type: "
<< in.type().name() << ", expected " << typeid(txin_to_key).name()
@@ -813,7 +812,7 @@ namespace cryptonote
//-----------------------------------------------------------------------------------------------
bool check_outs_valid(const transaction& tx)
{
- BOOST_FOREACH(const tx_out& out, tx.vout)
+ for(const tx_out& out: tx.vout)
{
CHECK_AND_ASSERT_MES(out.target.type() == typeid(txout_to_key), false, "wrong variant type: "
<< out.target.type().name() << ", expected " << typeid(txout_to_key).name()
@@ -838,7 +837,7 @@ namespace cryptonote
bool check_inputs_overflow(const transaction& tx)
{
uint64_t money = 0;
- BOOST_FOREACH(const auto& in, tx.vin)
+ for(const auto& in: tx.vin)
{
CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, tokey_in, false);
if(money > tokey_in.amount + money)
@@ -851,7 +850,7 @@ namespace cryptonote
bool check_outs_overflow(const transaction& tx)
{
uint64_t money = 0;
- BOOST_FOREACH(const auto& o, tx.vout)
+ for(const auto& o: tx.vout)
{
if(money > o.amount + money)
return false;
@@ -863,7 +862,7 @@ namespace cryptonote
uint64_t get_outs_money_amount(const transaction& tx)
{
uint64_t outputs_amount = 0;
- BOOST_FOREACH(const auto& o, tx.vout)
+ for(const auto& o: tx.vout)
outputs_amount += o.amount;
return outputs_amount;
}
@@ -905,7 +904,7 @@ namespace cryptonote
{
money_transfered = 0;
size_t i = 0;
- BOOST_FOREACH(const tx_out& o, tx.vout)
+ for(const tx_out& o: tx.vout)
{
CHECK_AND_ASSERT_MES(o.target.type() == typeid(txout_to_key), false, "wrong type id in transaction out" );
if(is_out_to_acc(acc, boost::get<txout_to_key>(o.target), tx_pub_key, i))
@@ -1177,7 +1176,7 @@ namespace cryptonote
size_t bl_sz = 0;
get_transaction_hash(b.miner_tx, h, bl_sz);
txs_ids.push_back(h);
- BOOST_FOREACH(auto& th, b.tx_hashes)
+ for(auto& th: b.tx_hashes)
txs_ids.push_back(th);
return get_tx_tree_hash(txs_ids);
}
diff --git a/src/cryptonote_core/miner.cpp b/src/cryptonote_core/miner.cpp
index 51f508858..88c631f80 100644
--- a/src/cryptonote_core/miner.cpp
+++ b/src/cryptonote_core/miner.cpp
@@ -33,7 +33,6 @@
#include <boost/utility/value_init.hpp>
#include <boost/interprocess/detail/atomic.hpp>
#include <boost/limits.hpp>
-#include <boost/foreach.hpp>
#include "misc_language.h"
#include "include_base_utils.h"
#include "cryptonote_basic_impl.h"
@@ -292,7 +291,7 @@ namespace cryptonote
send_stop_signal();
CRITICAL_REGION_LOCAL(m_threads_lock);
- BOOST_FOREACH(boost::thread& th, m_threads)
+ for(boost::thread& th: m_threads)
th.join();
MINFO("Mining has been stopped, " << m_threads.size() << " finished" );
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index 6ad139023..e37ddec0d 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -63,7 +63,7 @@ namespace cryptonote
size_t const TRANSACTION_SIZE_LIMIT_V2 = (((CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2 * 125) / 100) - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE);
time_t const MIN_RELAY_TIME = (60 * 5); // only start re-relaying transactions after that many seconds
time_t const MAX_RELAY_TIME = (60 * 60 * 4); // at most that many seconds between resends
- float const ACCEPT_THRESHOLD = 0.99f;
+ float const ACCEPT_THRESHOLD = 1.0f;
// a kind of increasing backoff within min/max bounds
time_t get_relay_delay(time_t now, time_t received)
@@ -240,7 +240,7 @@ namespace cryptonote
// assume failure during verification steps until success is certain
tvc.m_verifivation_failed = true;
- BOOST_FOREACH(const auto& in, tx.vin)
+ for(const auto& in: tx.vin)
{
CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, txin, false);
std::unordered_set<crypto::hash>& kei_image_set = m_spent_key_images[txin.k_image];
@@ -253,7 +253,7 @@ namespace cryptonote
tvc.m_verifivation_failed = false;
- m_txs_by_fee_and_receive_time.emplace(std::pair<double, std::time_t>((double)blob_size / fee, receive_time), id);
+ m_txs_by_fee_and_receive_time.emplace(std::pair<double, std::time_t>(fee / (double)blob_size, receive_time), id);
return true;
}
@@ -275,7 +275,7 @@ namespace cryptonote
// ND: Speedup
// 1. Move transaction hash calcuation outside of loop. ._.
crypto::hash actual_hash = get_transaction_hash(tx);
- BOOST_FOREACH(const txin_v& vi, tx.vin)
+ for(const txin_v& vi: tx.vin)
{
CHECKED_GET_SPECIFIC_VARIANT(vi, const txin_to_key, txin, false);
auto it = m_spent_key_images.find(txin.k_image);
@@ -415,7 +415,7 @@ namespace cryptonote
void tx_memory_pool::get_transactions(std::list<transaction>& txs) const
{
CRITICAL_REGION_LOCAL(m_transactions_lock);
- BOOST_FOREACH(const auto& tx_vt, m_transactions)
+ for(const auto& tx_vt: m_transactions)
txs.push_back(tx_vt.second.tx);
}
//------------------------------------------------------------------
@@ -488,7 +488,7 @@ namespace cryptonote
bool tx_memory_pool::have_tx_keyimges_as_spent(const transaction& tx) const
{
CRITICAL_REGION_LOCAL(m_transactions_lock);
- BOOST_FOREACH(const auto& in, tx.vin)
+ for(const auto& in: tx.vin)
{
CHECKED_GET_SPECIFIC_VARIANT(in, const txin_to_key, tokey_in, true);//should never fail
if(have_tx_keyimg_as_spent(tokey_in.k_image))
@@ -613,6 +613,10 @@ namespace cryptonote
uint64_t best_coinbase = 0;
total_size = 0;
fee = 0;
+
+ //baseline empty block
+ get_block_reward(median_size, total_size, already_generated_coins, best_coinbase, version);
+
size_t max_total_size = 2 * median_size - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE;
std::unordered_set<crypto::key_image> k_images;
@@ -641,7 +645,7 @@ namespace cryptonote
sorted_it++;
continue;
}
- uint64_t coinbase = block_reward + fee;
+ uint64_t coinbase = block_reward + fee + tx_it->second.fee;
if (coinbase < template_accept_threshold(best_coinbase))
{
LOG_PRINT_L2(" would decrease coinbase to " << print_money(coinbase));
@@ -728,7 +732,7 @@ namespace cryptonote
// no need to store queue of sorted transactions, as it's easy to generate.
for (const auto& tx : m_transactions)
{
- m_txs_by_fee_and_receive_time.emplace(std::pair<double, time_t>((double)tx.second.blob_size / tx.second.fee, tx.second.receive_time), tx.first);
+ m_txs_by_fee_and_receive_time.emplace(std::pair<double, time_t>(tx.second.fee / (double)tx.second.blob_size, tx.second.receive_time), tx.first);
}
// Ignore deserialization error