mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 19:39:22 +00:00
Tari: submit block code WIP
This commit is contained in:
parent
a5f3e1e2ee
commit
e8d800b433
2 changed files with 33 additions and 4 deletions
|
@ -124,10 +124,36 @@ bool MergeMiningClientTari::get_params(ChainParameters& out_params) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MergeMiningClientTari::submit_solution(const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof)
|
void MergeMiningClientTari::submit_solution(const std::vector<uint8_t>& /*blob*/, const std::vector<hash>& /*merkle_proof*/)
|
||||||
{
|
{
|
||||||
(void)blob;
|
Block block;
|
||||||
(void)merkle_proof;
|
{
|
||||||
|
ReadLock lock(m_chainParamsLock);
|
||||||
|
block = m_tariBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProofOfWork* pow = block.mutable_header()->mutable_pow();
|
||||||
|
pow->set_pow_algo(PowAlgo_PowAlgos_POW_ALGOS_RANDOMX);
|
||||||
|
|
||||||
|
// TODO fill in the data
|
||||||
|
std::string data;
|
||||||
|
pow->set_pow_data(data);
|
||||||
|
|
||||||
|
grpc::ClientContext ctx;
|
||||||
|
SubmitBlockResponse response;
|
||||||
|
|
||||||
|
const grpc::Status status = m_TariNode->SubmitBlock(&ctx, block, &response);
|
||||||
|
|
||||||
|
if (!status.ok()) {
|
||||||
|
LOGWARN(5, "SubmitBlock failed: " << status.error_message());
|
||||||
|
if (!status.error_details().empty()) {
|
||||||
|
LOGWARN(5, "SubmitBlock failed: " << status.error_details());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const std::string& h = response.block_hash();
|
||||||
|
LOGINFO(3, log::LightGreen() << "Mined Tari block " << log::hex_buf(h.data(), h.size()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MergeMiningClientTari::run_wrapper(void* arg)
|
void MergeMiningClientTari::run_wrapper(void* arg)
|
||||||
|
@ -154,7 +180,7 @@ void MergeMiningClientTari::run()
|
||||||
algo->set_pow_algo(PowAlgo_PowAlgos_POW_ALGOS_RANDOMX);
|
algo->set_pow_algo(PowAlgo_PowAlgos_POW_ALGOS_RANDOMX);
|
||||||
request.clear_algo();
|
request.clear_algo();
|
||||||
request.set_allocated_algo(algo);
|
request.set_allocated_algo(algo);
|
||||||
request.set_max_weight(1);
|
request.set_max_weight(0);
|
||||||
|
|
||||||
NewBlockCoinbase* coinbase = request.add_coinbases();
|
NewBlockCoinbase* coinbase = request.add_coinbases();
|
||||||
coinbase->set_address(m_auxWallet);
|
coinbase->set_address(m_auxWallet);
|
||||||
|
@ -204,6 +230,8 @@ void MergeMiningClientTari::run()
|
||||||
|
|
||||||
std::copy(mm_hash.begin(), mm_hash.end(), m_chainParams.aux_hash.h);
|
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());
|
m_chainParams.aux_diff = static_cast<difficulty_type>(response.miner_data().target_difficulty());
|
||||||
|
|
||||||
|
m_tariBlock = response.block();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGINFO(6, "Tari block template: height = " << response.block().header().height()
|
LOGINFO(6, "Tari block template: height = " << response.block().header().height()
|
||||||
|
|
|
@ -38,6 +38,7 @@ public:
|
||||||
private:
|
private:
|
||||||
mutable uv_rwlock_t m_chainParamsLock;
|
mutable uv_rwlock_t m_chainParamsLock;
|
||||||
ChainParameters m_chainParams;
|
ChainParameters m_chainParams;
|
||||||
|
tari::rpc::Block m_tariBlock;
|
||||||
|
|
||||||
std::string m_auxWallet;
|
std::string m_auxWallet;
|
||||||
p2pool* m_pool;
|
p2pool* m_pool;
|
||||||
|
|
Loading…
Reference in a new issue