mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-23 03:49:23 +00:00
Tari: fill in merge mining hash and difficulty
This commit is contained in:
parent
5f62069590
commit
a5f3e1e2ee
2 changed files with 33 additions and 21 deletions
|
@ -219,8 +219,9 @@ struct
|
||||||
#endif
|
#endif
|
||||||
difficulty_type
|
difficulty_type
|
||||||
{
|
{
|
||||||
FORCEINLINE constexpr difficulty_type() : lo(0), hi(0) {}
|
FORCEINLINE constexpr difficulty_type() noexcept : lo(0), hi(0) {}
|
||||||
FORCEINLINE constexpr difficulty_type(uint64_t a, uint64_t b) : lo(a), hi(b) {}
|
FORCEINLINE explicit constexpr difficulty_type(uint64_t a) noexcept : lo(a), hi(0) {}
|
||||||
|
FORCEINLINE constexpr difficulty_type(uint64_t a, uint64_t b) noexcept : lo(a), hi(b) {}
|
||||||
|
|
||||||
uint64_t lo;
|
uint64_t lo;
|
||||||
uint64_t hi;
|
uint64_t hi;
|
||||||
|
|
|
@ -178,31 +178,42 @@ void MergeMiningClientTari::run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bool aux_id_empty;
|
const std::string& id = response.tari_unique_id();
|
||||||
{
|
const std::string& mm_hash = response.merge_mining_hash();
|
||||||
ReadLock lock2(m_chainParamsLock);
|
|
||||||
aux_id_empty = m_chainParams.aux_id.empty();
|
bool ok = true;
|
||||||
|
|
||||||
|
if (id.size() != HASH_SIZE) {
|
||||||
|
LOGERR(1, "Tari unique_id has invalid size (" << id.size() << ')');
|
||||||
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aux_id_empty) {
|
if (mm_hash.size() != HASH_SIZE) {
|
||||||
const std::string& id = response.tari_unique_id();
|
LOGERR(1, "Tari merge mining hash has invalid size (" << mm_hash.size() << ')');
|
||||||
LOGINFO(1, m_hostStr << " uses chain_id " << log::LightCyan() << log::hex_buf(id.data(), id.size()));
|
ok = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (id.size() == HASH_SIZE) {
|
if (ok) {
|
||||||
|
{
|
||||||
WriteLock lock2(m_chainParamsLock);
|
WriteLock lock2(m_chainParamsLock);
|
||||||
|
|
||||||
|
if (m_chainParams.aux_id.empty()) {
|
||||||
|
LOGINFO(1, m_hostStr << " uses chain_id " << log::LightCyan() << log::hex_buf(id.data(), id.size()));
|
||||||
std::copy(id.begin(), id.end(), m_chainParams.aux_id.h);
|
std::copy(id.begin(), id.end(), m_chainParams.aux_id.h);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
LOGERR(1, "Tari unique_id has invalid size (" << id.size() << ')');
|
std::copy(mm_hash.begin(), mm_hash.end(), m_chainParams.aux_hash.h);
|
||||||
}
|
m_chainParams.aux_diff = static_cast<difficulty_type>(response.miner_data().target_difficulty());
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGINFO(6, "Tari block template: height = " << response.block().header().height()
|
LOGINFO(6, "Tari block template: height = " << response.block().header().height()
|
||||||
<< ", diff = " << response.miner_data().target_difficulty()
|
<< ", diff = " << response.miner_data().target_difficulty()
|
||||||
<< ", reward = " << response.miner_data().reward()
|
<< ", reward = " << response.miner_data().reward()
|
||||||
<< ", fees = " << response.miner_data().total_fees()
|
<< ", fees = " << response.miner_data().total_fees()
|
||||||
|
<< ", hash = " << log::hex_buf(mm_hash.data(), mm_hash.size())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const int64_t timeout = std::max<int64_t>(500'000'000 - duration_cast<nanoseconds>(high_resolution_clock::now() - t1).count(), 1'000'000);
|
const int64_t timeout = std::max<int64_t>(500'000'000 - duration_cast<nanoseconds>(high_resolution_clock::now() - t1).count(), 1'000'000);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue