aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_basic
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-10-31 01:05:58 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-10-31 01:06:42 +0000
commitebc6ce44f407fab07955fc230f4cab59742fd959 (patch)
treee440ac44d8fb69c6f53d93252814c6b679fc89da /src/cryptonote_basic
parentMerge pull request #6044 (diff)
downloadmonero-ebc6ce44f407fab07955fc230f4cab59742fd959.tar.xz
cryptonote: untangle dependency from miner to blockchain
It causes link errors at least on mac
Diffstat (limited to 'src/cryptonote_basic')
-rw-r--r--src/cryptonote_basic/miner.cpp10
-rw-r--r--src/cryptonote_basic/miner.h8
2 files changed, 9 insertions, 9 deletions
diff --git a/src/cryptonote_basic/miner.cpp b/src/cryptonote_basic/miner.cpp
index c4b5c8455..688aeaea3 100644
--- a/src/cryptonote_basic/miner.cpp
+++ b/src/cryptonote_basic/miner.cpp
@@ -102,13 +102,13 @@ namespace cryptonote
}
- miner::miner(i_miner_handler* phandler, Blockchain* pbc):m_stop(1),
+ miner::miner(i_miner_handler* phandler, const get_block_hash_t &gbh):m_stop(1),
m_template{},
m_template_no(0),
m_diffic(0),
m_thread_index(0),
m_phandler(phandler),
- m_pbc(pbc),
+ m_gbh(gbh),
m_height(0),
m_threads_active(0),
m_pausers_count(0),
@@ -471,12 +471,12 @@ namespace cryptonote
return true;
}
//-----------------------------------------------------------------------------------------------------
- bool miner::find_nonce_for_given_block(const Blockchain *pbc, block& bl, const difficulty_type& diffic, uint64_t height)
+ bool miner::find_nonce_for_given_block(const get_block_hash_t &gbh, block& bl, const difficulty_type& diffic, uint64_t height)
{
for(; bl.nonce != std::numeric_limits<uint32_t>::max(); bl.nonce++)
{
crypto::hash h;
- get_block_longhash(pbc, bl, h, height, tools::get_max_concurrency());
+ gbh(bl, height, tools::get_max_concurrency(), h);
if(check_hash(h, diffic))
{
@@ -572,7 +572,7 @@ namespace cryptonote
b.nonce = nonce;
crypto::hash h;
- get_block_longhash(m_pbc, b, h, height, tools::get_max_concurrency());
+ m_gbh(b, height, tools::get_max_concurrency(), h);
if(check_hash(h, local_diff))
{
diff --git a/src/cryptonote_basic/miner.h b/src/cryptonote_basic/miner.h
index 4efbcbec3..ce50d674e 100644
--- a/src/cryptonote_basic/miner.h
+++ b/src/cryptonote_basic/miner.h
@@ -52,7 +52,7 @@ namespace cryptonote
~i_miner_handler(){};
};
- class Blockchain;
+ typedef std::function<bool(const cryptonote::block&, uint64_t, unsigned int, crypto::hash&)> get_block_hash_t;
/************************************************************************/
/* */
@@ -60,7 +60,7 @@ namespace cryptonote
class miner
{
public:
- miner(i_miner_handler* phandler, Blockchain* pbc);
+ miner(i_miner_handler* phandler, const get_block_hash_t& gbh);
~miner();
bool init(const boost::program_options::variables_map& vm, network_type nettype);
static void init_options(boost::program_options::options_description& desc);
@@ -76,7 +76,7 @@ namespace cryptonote
bool on_idle();
void on_synchronized();
//synchronous analog (for fast calls)
- static bool find_nonce_for_given_block(const Blockchain *pbc, block& bl, const difficulty_type& diffic, uint64_t height);
+ static bool find_nonce_for_given_block(const get_block_hash_t &gbh, block& bl, const difficulty_type& diffic, uint64_t height);
void pause();
void resume();
void do_print_hashrate(bool do_hr);
@@ -135,7 +135,7 @@ namespace cryptonote
std::list<boost::thread> m_threads;
epee::critical_section m_threads_lock;
i_miner_handler* m_phandler;
- Blockchain* m_pbc;
+ get_block_hash_t m_gbh;
account_public_address m_mine_address;
epee::math_helper::once_a_time_seconds<5> m_update_block_template_interval;
epee::math_helper::once_a_time_seconds<2> m_update_merge_hr_interval;