mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-23 03:49:23 +00:00
Sync test fixes
This commit is contained in:
parent
5aff5f5796
commit
394b4f310e
3 changed files with 17 additions and 5 deletions
2
external/src/crypto/sha256.c
vendored
2
external/src/crypto/sha256.c
vendored
|
@ -49,7 +49,7 @@ static void sha256_transform(SHA256_CTX *ctx, const uint8_t* data)
|
||||||
uint32_t a, b, c, d, e, f, g, h, i, j, t1, t2, m[64];
|
uint32_t a, b, c, d, e, f, g, h, i, j, t1, t2, m[64];
|
||||||
|
|
||||||
for (i = 0, j = 0; i < 16; ++i, j += 4)
|
for (i = 0, j = 0; i < 16; ++i, j += 4)
|
||||||
m[i] = (data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]);
|
m[i] = (((uint32_t)data[j]) << 24) | (((uint32_t)data[j + 1]) << 16) | (((uint32_t)data[j + 2]) << 8) | ((uint32_t)data[j + 3]);
|
||||||
for ( ; i < 64; ++i)
|
for ( ; i < 64; ++i)
|
||||||
m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
|
m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,8 @@ MergeMiningClient::MergeMiningClient(p2pool* pool, const std::string& host, cons
|
||||||
}
|
}
|
||||||
m_timer.data = this;
|
m_timer.data = this;
|
||||||
|
|
||||||
|
uv_rwlock_init_checked(&m_lock);
|
||||||
|
|
||||||
err = uv_thread_create(&m_loopThread, loop, this);
|
err = uv_thread_create(&m_loopThread, loop, this);
|
||||||
if (err) {
|
if (err) {
|
||||||
LOGERR(1, "failed to start event loop thread, error " << uv_err_name(err));
|
LOGERR(1, "failed to start event loop thread, error " << uv_err_name(err));
|
||||||
|
@ -93,13 +95,15 @@ MergeMiningClient::~MergeMiningClient()
|
||||||
uv_async_send(&m_shutdownAsync);
|
uv_async_send(&m_shutdownAsync);
|
||||||
uv_thread_join(&m_loopThread);
|
uv_thread_join(&m_loopThread);
|
||||||
|
|
||||||
|
uv_rwlock_destroy(&m_lock);
|
||||||
|
|
||||||
LOGINFO(1, "stopped");
|
LOGINFO(1, "stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MergeMiningClient::on_timer()
|
void MergeMiningClient::on_timer()
|
||||||
{
|
{
|
||||||
MinerData data = m_pool->miner_data();
|
MinerData data = m_pool->miner_data();
|
||||||
merge_mining_get_job(data.height, data.prev_id, m_auxWallet, m_auxHash);
|
merge_mining_get_job(data.height, data.prev_id, m_auxWallet, aux_data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MergeMiningClient::merge_mining_get_chain_id()
|
void MergeMiningClient::merge_mining_get_chain_id()
|
||||||
|
@ -108,6 +112,8 @@ void MergeMiningClient::merge_mining_get_chain_id()
|
||||||
|
|
||||||
JSONRPCRequest::call(m_host, m_port, req, std::string(), m_pool->params().m_socks5Proxy,
|
JSONRPCRequest::call(m_host, m_port, req, std::string(), m_pool->params().m_socks5Proxy,
|
||||||
[this](const char* data, size_t size, double ping) {
|
[this](const char* data, size_t size, double ping) {
|
||||||
|
WriteLock lock(m_lock);
|
||||||
|
|
||||||
if (parse_merge_mining_get_chain_id(data, size)) {
|
if (parse_merge_mining_get_chain_id(data, size)) {
|
||||||
if (ping > 0.0) {
|
if (ping > 0.0) {
|
||||||
m_ping = ping;
|
m_ping = ping;
|
||||||
|
@ -192,6 +198,8 @@ void MergeMiningClient::merge_mining_get_job(uint64_t height, const hash& prev_i
|
||||||
|
|
||||||
JSONRPCRequest::call(m_host, m_port, std::string(buf, s.m_pos), std::string(), m_pool->params().m_socks5Proxy,
|
JSONRPCRequest::call(m_host, m_port, std::string(buf, s.m_pos), std::string(), m_pool->params().m_socks5Proxy,
|
||||||
[this](const char* data, size_t size, double) {
|
[this](const char* data, size_t size, double) {
|
||||||
|
WriteLock lock(m_lock);
|
||||||
|
|
||||||
parse_merge_mining_get_job(data, size);
|
parse_merge_mining_get_job(data, size);
|
||||||
},
|
},
|
||||||
[this](const char* data, size_t size, double) {
|
[this](const char* data, size_t size, double) {
|
||||||
|
@ -260,6 +268,8 @@ bool MergeMiningClient::parse_merge_mining_get_job(const char* data, size_t size
|
||||||
|
|
||||||
void MergeMiningClient::merge_mining_submit_solution(const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof)
|
void MergeMiningClient::merge_mining_submit_solution(const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof)
|
||||||
{
|
{
|
||||||
|
ReadLock lock(m_lock);
|
||||||
|
|
||||||
std::vector<char> buf((m_auxBlob.size() + HASH_SIZE + blob.size()) * 2 + merkle_proof.size() * (HASH_SIZE * 2 + 3) + 256);
|
std::vector<char> buf((m_auxBlob.size() + HASH_SIZE + blob.size()) * 2 + merkle_proof.size() * (HASH_SIZE * 2 + 3) + 256);
|
||||||
log::Stream s(buf.data(), buf.size());
|
log::Stream s(buf.data(), buf.size());
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,9 @@ public:
|
||||||
|
|
||||||
void merge_mining_submit_solution(const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof);
|
void merge_mining_submit_solution(const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof);
|
||||||
|
|
||||||
FORCEINLINE const hash& aux_id() const { return m_chainID; }
|
FORCEINLINE hash aux_id() const { ReadLock lock(m_lock); return m_chainID; }
|
||||||
FORCEINLINE const hash& aux_data() const { return m_auxHash; }
|
FORCEINLINE hash aux_data() const { ReadLock lock(m_lock); return m_auxHash; }
|
||||||
FORCEINLINE const difficulty_type& aux_diff() const { return m_auxDiff; }
|
FORCEINLINE difficulty_type aux_diff() const { ReadLock lock(m_lock); return m_auxDiff; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void loop(void* data);
|
static void loop(void* data);
|
||||||
|
@ -52,6 +52,8 @@ private:
|
||||||
std::string m_host;
|
std::string m_host;
|
||||||
uint32_t m_port;
|
uint32_t m_port;
|
||||||
|
|
||||||
|
mutable uv_rwlock_t m_lock;
|
||||||
|
|
||||||
std::string m_auxWallet;
|
std::string m_auxWallet;
|
||||||
std::vector<uint8_t> m_auxBlob;
|
std::vector<uint8_t> m_auxBlob;
|
||||||
hash m_auxHash;
|
hash m_auxHash;
|
||||||
|
|
Loading…
Reference in a new issue