mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-08-18 20:48:46 -06:00
Fix RandomX startup logic
Ensure that both RandomX caches initialize before stratum and p2p servers start.
This commit is contained in:
parent
276cc5f0fd
commit
0009eba307
@ -393,7 +393,8 @@ void p2pool::download_block_headers(uint64_t current_height)
|
|||||||
ChainMain block;
|
ChainMain block;
|
||||||
if (parse_block_header(data, size, block)) {
|
if (parse_block_header(data, size, block)) {
|
||||||
if (height == prev_seed_height) {
|
if (height == prev_seed_height) {
|
||||||
m_hasher->set_old_seed_async(block.id);
|
// Do it synchronously to make sure stratum and p2p don't start before it's finished
|
||||||
|
m_hasher->set_old_seed(block.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -147,39 +147,6 @@ void RandomX_Hasher::set_seed_async(const hash& seed)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RandomX_Hasher::set_old_seed_async(const hash& seed)
|
|
||||||
{
|
|
||||||
struct Work
|
|
||||||
{
|
|
||||||
p2pool* pool;
|
|
||||||
RandomX_Hasher* hasher;
|
|
||||||
hash seed;
|
|
||||||
uv_work_t req;
|
|
||||||
};
|
|
||||||
|
|
||||||
Work* work = new Work{};
|
|
||||||
work->pool = m_pool;
|
|
||||||
work->hasher = this;
|
|
||||||
work->seed = seed;
|
|
||||||
work->req.data = work;
|
|
||||||
|
|
||||||
uv_queue_work(uv_default_loop_checked(), &work->req,
|
|
||||||
[](uv_work_t* req)
|
|
||||||
{
|
|
||||||
bkg_jobs_tracker.start("RandomX_Hasher::set_old_seed_async");
|
|
||||||
Work* work = reinterpret_cast<Work*>(req->data);
|
|
||||||
if (!work->pool->stopped()) {
|
|
||||||
work->hasher->set_old_seed(work->seed);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[](uv_work_t* req, int)
|
|
||||||
{
|
|
||||||
delete reinterpret_cast<Work*>(req->data);
|
|
||||||
bkg_jobs_tracker.stop("RandomX_Hasher::set_old_seed_async");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RandomX_Hasher::set_seed(const hash& seed)
|
void RandomX_Hasher::set_seed(const hash& seed)
|
||||||
{
|
{
|
||||||
if (m_stopped.load()) {
|
if (m_stopped.load()) {
|
||||||
|
@ -34,13 +34,12 @@ public:
|
|||||||
~RandomX_Hasher();
|
~RandomX_Hasher();
|
||||||
|
|
||||||
void set_seed_async(const hash& seed);
|
void set_seed_async(const hash& seed);
|
||||||
void set_old_seed_async(const hash& seed);
|
void set_old_seed(const hash& seed);
|
||||||
|
|
||||||
bool calculate(const void* data, size_t size, const hash& seed, hash& result);
|
bool calculate(const void* data, size_t size, const hash& seed, hash& result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void set_seed(const hash& seed);
|
void set_seed(const hash& seed);
|
||||||
void set_old_seed(const hash& seed);
|
|
||||||
|
|
||||||
struct ThreadSafeVM
|
struct ThreadSafeVM
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user