Compare commits

...

5 Commits

Author SHA1 Message Date
SChernykh 42370bf11e p2pool v1.7 2022-02-14 19:29:55 +01:00
SChernykh dc506bb1b9 Update README.md 2022-02-14 14:08:36 +01:00
SChernykh ec2f4467fb Added --mini command line option to connect to p2pool-mini 2022-02-14 13:57:59 +01:00
SChernykh 9f449320b5 StartumServer: disconnect and ban inactive clients 2022-02-08 15:00:08 +01:00
SChernykh 8767ef9e19 Display payout amount when a block is found 2022-01-29 17:09:43 +01:00
13 changed files with 66 additions and 9 deletions
+2
View File
@@ -60,6 +60,7 @@ This guide assumes that you run everything on the same machine. If it's not the
- Official Monero CLI and GUI v0.17.2.3 and newer
- Monerujo v2.1.0 "Vertant" and newer
- Cake Wallet v4.2.7 and newer
- Feather Wallet v1.0.0 and newer
- MyMonero
**General Considerations**
@@ -68,6 +69,7 @@ This guide assumes that you run everything on the same machine. If it's not the
- You have to use the primary wallet address for mining. Subaddresses and integrated addresses are not supported, just like with monerod solo mining.
- Check that ports 18080 (Monero p2p port) and 37889 (p2pool p2p port) are open in your firewall to ensure better connectivity. If you're mining from a computer behind NAT (like a router) you could consider forwarding the ports to your local machine.
- You can connect multiple miners to the same p2pool node. The more the better!
- Starting from p2pool v1.7, you can add `--mini` to p2pool command line to connect to the **p2pool-mini** sidechain. Note that it will also change the default p2p port from 37889 to 37888.
Step-by-step guide:
+3
View File
@@ -44,11 +44,14 @@ static void usage()
"--out-peers N Maximum number of outgoing connections for p2p server (any value between 10 and 1000)\n"
"--in-peers N Maximum number of incoming connections for p2p server (any value between 10 and 1000)\n"
"--start-mining N Start built-in miner using N threads (any value between 1 and 64)\n"
"--mini Connect to p2pool-mini sidechain. Note that it will also change default p2p port from %d to %d.\n"
"--help Show this help message\n\n"
"Example command line:\n\n"
"%s --host 127.0.0.1 --rpc-port 18081 --zmq-port 18083 --wallet YOUR_WALLET_ADDRESS --stratum 0.0.0.0:%d --p2p 0.0.0.0:%d\n\n",
p2pool::VERSION,
p2pool::log::MAX_GLOBAL_LOG_LEVEL,
p2pool::DEFAULT_P2P_PORT,
p2pool::DEFAULT_P2P_PORT_MINI,
#ifdef _WIN32
"p2pool.exe"
#else
+8 -2
View File
@@ -32,6 +32,7 @@
#include "console_commands.h"
#include "crypto.h"
#include "p2pool_api.h"
#include "pool_block.h"
#include <thread>
#include <fstream>
@@ -110,7 +111,7 @@ p2pool::p2pool(int argc, char* argv[])
m_api = m_params->m_apiPath.empty() ? nullptr : new p2pool_api(m_params->m_apiPath, m_params->m_localStats);
m_sideChain = new SideChain(this, type);
m_sideChain = new SideChain(this, type, m_params->m_mini ? "mini" : nullptr);
if (m_params->m_p2pAddresses.empty()) {
const int p2p_port = m_sideChain->is_mini() ? DEFAULT_P2P_PORT_MINI : DEFAULT_P2P_PORT;
@@ -339,8 +340,13 @@ void p2pool::handle_chain_main(ChainMain& data, const char* extra)
", reward = " << log::Gray() << log::XMRAmount(data.reward));
if (!sidechain_id.empty()) {
if (side_chain().has_block(sidechain_id)) {
PoolBlock* block = side_chain().find_block(sidechain_id);
if (block) {
LOGINFO(0, log::LightGreen() << "BLOCK FOUND: main chain block at height " << data.height << " was mined by this p2pool" << BLOCK_FOUND);
const uint64_t payout = block->get_payout(params().m_wallet);
if (payout) {
LOGINFO(0, log::LightCyan() << "You received a payout of " << log::LightGreen() << log::XMRAmount(payout) << log::LightCyan() << " in block " << log::LightGreen() << data.height);
}
api_update_block_found(&data);
}
else {
+4
View File
@@ -97,6 +97,10 @@ Params::Params(int argc, char* argv[])
if ((strcmp(argv[i], "--start-mining") == 0) && (i + 1 < argc)) {
m_minerThreads = std::min(std::max(strtoul(argv[++i], nullptr, 10), 1UL), 64UL);
}
if (strcmp(argv[i], "--mini") == 0) {
m_mini = true;
}
}
if (m_stratumAddresses.empty()) {
+1
View File
@@ -43,6 +43,7 @@ struct Params
uint32_t m_maxOutgoingPeers = 10;
uint32_t m_maxIncomingPeers = 1000;
uint32_t m_minerThreads = 0;
bool m_mini = false;
};
} // namespace p2pool
+12
View File
@@ -298,4 +298,16 @@ bool PoolBlock::get_pow_hash(RandomX_Hasher_Base* hasher, uint64_t height, const
return hasher->calculate(blob, blob_size, height, seed_hash, pow_hash);
}
uint64_t PoolBlock::get_payout(const Wallet& w) const
{
for (size_t i = 0, n = m_outputs.size(); i < n; ++i) {
hash eph_public_key;
if ((w.get_eph_public_key(m_txkeySec, i, eph_public_key)) && (eph_public_key == m_outputs[i].m_ephPublicKey)) {
return m_outputs[i].m_reward;
}
}
return 0;
}
} // namespace p2pool
+2
View File
@@ -137,6 +137,8 @@ struct PoolBlock
int deserialize(const uint8_t* data, size_t size, SideChain& sidechain);
bool get_pow_hash(RandomX_Hasher_Base* hasher, uint64_t height, const hash& seed_hash, hash& pow_hash);
uint64_t get_payout(const Wallet& w) const;
};
} // namespace p2pool
+13 -2
View File
@@ -481,6 +481,11 @@ bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_
m_watchBlockSidechainId = {};
data = m_watchBlock;
block_found = true;
const uint64_t payout = block.get_payout(m_pool->params().m_wallet);
if (payout) {
LOGINFO(0, log::LightCyan() << "You received a payout of " << log::LightGreen() << log::XMRAmount(payout) << log::LightCyan() << " in block " << log::LightGreen() << data.height);
}
}
}
@@ -536,10 +541,16 @@ void SideChain::add_block(const PoolBlock& block)
m_seenWallets[new_block->m_minerWallet.spend_public_key()] = new_block->m_localTimestamp;
}
bool SideChain::has_block(const hash& id)
PoolBlock* SideChain::find_block(const hash& id)
{
MutexLock lock(m_sidechainLock);
return m_blocksById.find(id) != m_blocksById.end();
auto it = m_blocksById.find(id);
if (it != m_blocksById.end()) {
return it->second;
}
return nullptr;
}
void SideChain::watch_mainchain_block(const ChainMain& data, const hash& possible_id)
+1 -1
View File
@@ -51,7 +51,7 @@ public:
void add_block(const PoolBlock& block);
void get_missing_blocks(std::vector<hash>& missing_blocks);
bool has_block(const hash& id);
PoolBlock* find_block(const hash& id);
void watch_mainchain_block(const ChainMain& data, const hash& possible_id);
bool get_block_blob(const hash& id, std::vector<uint8_t>& blob);
+16 -1
View File
@@ -516,6 +516,8 @@ void StratumServer::on_blobs_ready()
size_t numClientsProcessed = 0;
uint32_t extra_nonce = 0;
const time_t cur_time = time(nullptr);
{
MutexLock lock2(m_clientsListLock);
@@ -523,7 +525,12 @@ void StratumServer::on_blobs_ready()
++numClientsProcessed;
if (!client->m_rpcId) {
// Not logged in yet, on_login() will send the job to this client
// Not logged in yet, on_login() will send the job to this client. Also close inactive connections.
if (cur_time >= client->m_connectedTime + 10) {
LOGWARN(4, "client " << static_cast<char*>(client->m_addrString) << " didn't send login data");
client->ban(DEFAULT_BAN_TIME);
client->close();
}
continue;
}
@@ -760,6 +767,7 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
StratumServer::StratumClient::StratumClient()
: m_rpcId(0)
, m_connectedTime(0)
, m_jobs{}
, m_perConnectionJobId(0)
, m_customDiff{}
@@ -776,12 +784,19 @@ void StratumServer::StratumClient::reset()
{
Client::reset();
m_rpcId = 0;
m_connectedTime = 0;
memset(m_jobs, 0, sizeof(m_jobs));
m_perConnectionJobId = 0;
m_customDiff = {};
m_customUser.clear();
}
bool StratumServer::StratumClient::on_connect()
{
m_connectedTime = time(nullptr);
return true;
}
bool StratumServer::StratumClient::on_read(char* data, uint32_t size)
{
if ((data != m_readBuf + m_numRead) || (data + size > m_readBuf + sizeof(m_readBuf))) {
+2 -1
View File
@@ -45,7 +45,7 @@ public:
static Client* allocate() { return new StratumClient(); }
void reset() override;
bool on_connect() override { return true; }
bool on_connect() override;
bool on_read(char* data, uint32_t size) override;
bool process_request(char* data, uint32_t size);
@@ -53,6 +53,7 @@ public:
bool process_submit(rapidjson::Document& doc, uint32_t id);
uint32_t m_rpcId;
time_t m_connectedTime;
uv_mutex_t m_jobsLock;
+1 -1
View File
@@ -32,7 +32,7 @@ namespace p2pool {
#define STR2(X) STR(X)
#define STR(X) #X
const char* VERSION = "v1.6 (built"
const char* VERSION = "v1.7 (built"
#if defined(__clang__)
" with clang/" __clang_version__
#elif defined(__GNUC__)
+1 -1
View File
@@ -125,7 +125,7 @@ TEST(pool_block, verify)
p += n;
sidechain.add_block(b);
ASSERT_TRUE(sidechain.has_block(b.m_sidechainId));
ASSERT_TRUE(sidechain.find_block(b.m_sidechainId) != nullptr);
}
const PoolBlock* tip = sidechain.chainTip();