Compare commits

...
29 Commits
Author SHA1 Message Date
SChernykhandGitHub c8248b2d33 Merge pull request #230 from hinto-janaiyo/master
README: Update Gupax info
2023-01-22 09:57:34 +01:00
hinto-janaiyoandGitHub d73b506d09 readme: update gupax info 2023-01-22 02:44:47 +00:00
SChernykh ccc5117172 Track shares that failed to be added 2023-01-07 15:50:02 +01:00
SChernykh b346b93285 Updated copyright 2023-01-04 13:07:55 +01:00
SChernykh 2b61c1d90f p2pool v2.7 2023-01-03 15:53:03 +01:00
SChernykh baf5a64c51 Add high fee transactions immediately 2023-01-02 14:32:13 +01:00
SChernykh 260564cff1 Check for NO_COLOR before logging starts 2023-01-01 22:12:16 +01:00
SChernykh 248f74d948 Updated libzmq 2023-01-01 15:55:50 +01:00
SChernykh 724a9e49df Updated curl to 7.87.0 2023-01-01 15:26:35 +01:00
SChernykh 726224b253 Support NO_COLOR environment variable 2023-01-01 11:47:13 +01:00
SChernykh 421e087d81 Fixed UV thread pool size 2022-12-26 19:52:15 +01:00
SChernykh a1ec97a221 Fixed submit_block error logging 2022-12-25 16:23:57 +01:00
SChernykh d151ed9354 Miner: fixed share counter reset logic 2022-12-22 21:53:04 +01:00
SChernykh 7502481f26 Fixed cppcheck issues 2022-12-22 21:00:59 +01:00
SChernykh 76e7e4956d Miner: fixed share counting during initial sync 2022-12-22 20:53:23 +01:00
SChernykh 15d25bca27 Fixed data race 2022-12-22 20:30:20 +01:00
SChernykh dffc8bcea0 Fixed cppcheck issues 2022-12-22 14:08:49 +01:00
SChernykh a61966ed61 Don't count shares that were found during sync 2022-12-22 11:48:50 +01:00
SChernykh e6d77a40e2 Check block major version in deserialize() 2022-12-19 10:29:29 +01:00
SChernykh edcb933874 Call get_miner_data again after startup is done
Startup sequence can take a while, so miner data can change - new transactions added, or a new block found by the network.
2022-12-18 11:46:18 +01:00
SChernykh be18ad4177 Made payout messages more visible 2022-12-18 11:06:38 +01:00
SChernykh 07a5b191bb Fixes for different BSD variants 2022-12-17 12:56:32 +01:00
SChernykh da12b329be Check the block id returned by BLOCK_RESPONSE 2022-12-14 14:24:09 +01:00
SChernykh 3902612c4b P2PServer: show more data for connected peers 2022-12-09 11:31:05 +01:00
SChernykh 9bce415523 Added alternative command line parameter names 2022-12-03 21:21:02 +01:00
SChernykh 3e4f877ec0 Display software name in peers list 2022-12-02 15:43:20 +01:00
SChernykh 1b601343ff Updated recommended command lines 2022-11-30 14:19:44 +01:00
SChernykh 77ee46e153 Updated RandomX 2022-11-30 10:40:25 +01:00
SChernykh 357c1a20df Updated recommended monerod command line 2022-11-29 11:33:55 +01:00
67 changed files with 532 additions and 154 deletions
+7
View File
@@ -25,6 +25,7 @@ include(cmake/flags.cmake)
set(HEADERS
external/src/cryptonote/crypto-ops.h
external/src/hardforks/hardforks.h
src/block_cache.h
src/block_template.h
src/common.h
@@ -55,6 +56,7 @@ set(HEADERS
set(SOURCES
external/src/cryptonote/crypto-ops-data.c
external/src/cryptonote/crypto-ops.c
external/src/hardforks/hardforks.cpp
src/block_cache.cpp
src/block_template.cpp
src/console_commands.cpp
@@ -184,6 +186,7 @@ include(CheckCXXSourceCompiles)
check_cxx_source_compiles("int main(){ return __builtin_clzll(1);}" HAVE_BUILTIN_CLZLL)
check_cxx_source_compiles("#include <intrin.h>\n#pragma intrinsic(_BitScanReverse64)\nint main(){unsigned long r;_BitScanReverse64(&r,1);return r;}" HAVE_BITSCANREVERSE64)
check_cxx_source_compiles("#include <sched.h>\nint main(){sched_param param;return sched_setscheduler(0, SCHED_IDLE, &param);}" HAVE_SCHED)
if (HAVE_BUILTIN_CLZLL)
add_definitions(/DHAVE_BUILTIN_CLZLL)
@@ -193,6 +196,10 @@ if (HAVE_BITSCANREVERSE64)
add_definitions(/DHAVE_BITSCANREVERSE64)
endif()
if (HAVE_SCHED)
add_definitions(/DHAVE_SCHED)
endif()
add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES})
if (STATIC_BINARY OR STATIC_LIBS)
+26 -6
View File
@@ -24,6 +24,7 @@ Pool status and monitoring pages can be found at https://p2pool.io/, https://p2p
- [Monero version support](#monero-version-support)
- [How to mine on P2Pool](#how-to-mine-on-p2pool)
- [General Considerations](#general-considerations)
- [GUI for P2Pool](#gui-for-p2pool)
- [GNU/Linux](#gnulinux)
- [Windows](#windows)
- [Build instructions](#build-instructions)
@@ -97,7 +98,7 @@ Monero network upgrade happened on August 13th, 2022 (block 2,688,888). In order
### GUI for P2Pool
- [Gupax](https://github.com/hinto-janaiyo/gupax) project (currently in development) aims to provide an easy to use GUI to configure and run monerod/p2pool/xmrig
- [Gupax](https://github.com/hinto-janaiyo/gupax) project aims to provide an easy to use cross-platform GUI to configure and run P2Pool & [XMRig](https://github.com/xmrig/xmrig).
### GNU/Linux
@@ -111,9 +112,19 @@ sudo sysctl vm.nr_hugepages=3072
4. Check that ports 18080 (Monero p2p port) and 37889/37888 (P2Pool/P2Pool mini p2p port) are open in your local firewall to ensure better connectivity.
5. Start `monerod` with the following command/options:
```
./monerod --zmq-pub tcp://127.0.0.1:18083 --disable-dns-checkpoints --enable-dns-blocklist
./monerod --zmq-pub tcp://127.0.0.1:18083 --out-peers 64 --in-peers 32 --add-priority-node=node.supportxmr.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --disable-dns-checkpoints --enable-dns-blocklist
```
**Note:** The `--zmq-pub` option is required for P2Pool to work properly.
**Note:**
The `--zmq-pub` option is required for P2Pool to work properly.
`--out-peers 64 --in-peers 32` is needed to (1) have many connections to other nodes and (2) limit incoming connection count because it can grow uncontrollably and cause problems when it goes above 1000 (open files limit in Linux). If your network connection's **upload** bandwidth is less than **10 Mbit**, use `--out-peers 16 --in-peers 8` instead.
`--add-priority-node=node.supportxmr.com:18080 --add-priority-node=nodes.hashvault.pro:18080` is needed to have guaranteed good working nodes in your connected peers.
`--disable-dns-checkpoints` is needed to avoid periodical lags when DNS is updated (it's not needed when mining)
`--enable-dns-blocklist` is needed to ban known bad nodes
6. Start P2Pool with the following command/options:
```
@@ -169,9 +180,18 @@ nocreate
8. Start `monerod` with the following command/options:
```
.\Monero\monerod.exe --zmq-pub tcp://127.0.0.1:18083 --disable-dns-checkpoints --enable-dns-blocklist
.\Monero\monerod.exe --zmq-pub tcp://127.0.0.1:18083 --out-peers 64 --in-peers 32 --add-priority-node=node.supportxmr.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --disable-dns-checkpoints --enable-dns-blocklist
```
**Note:** The `--zmq-pub` option is required for P2Pool to work properly.
**Note:**
The `--zmq-pub` option is required for P2Pool to work properly.
`--out-peers 64 --in-peers 32` is needed to (1) have many connections to other nodes and (2) limit incoming connection count because it can grow uncontrollably and cause problems when it goes above 1000 (open files limit in Linux). If your network connection's **upload** bandwidth is less than **10 Mbit**, use `--out-peers 16 --in-peers 8` instead.
`--add-priority-node=node.supportxmr.com:18080 --add-priority-node=nodes.hashvault.pro:18080` is needed to have guaranteed good working nodes in your connected peers.
`--disable-dns-checkpoints` is needed to avoid periodical lags when DNS is updated (it's not needed when mining)
`--enable-dns-blocklist` is needed to ban known bad nodes
9. Start P2Pool with the following command/options:
```
@@ -191,7 +211,7 @@ nocreate
13. *(Optional but highly recommended)* You can create a Quickstart by creating a batch (.bat) file with the following contents and placing it in your P2Pool directory along with `xmrig.exe`.
```
@ECHO OFF
start cmd /k %~dp0\Monero\monerod.exe --zmq-pub tcp://127.0.0.1:18083 --disable-dns-checkpoints --enable-dns-blocklist
start cmd /k %~dp0\Monero\monerod.exe --zmq-pub tcp://127.0.0.1:18083 --out-peers 64 --in-peers 32 --add-priority-node=node.supportxmr.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --disable-dns-checkpoints --enable-dns-blocklist
ECHO Wait until the Monero daemon shows fully synced before continuing. This can take some time. Type 'status' in other window to check progress.
PAUSE
start cmd /k %~dp0\p2pool.exe --wallet YOUR_WALLET_ADDRESS --mini
+1
View File
@@ -1,3 +1,4 @@
unmatchedSuppression
missingIncludeSystem
unusedFunction
useStlAlgorithm
+4
View File
@@ -119,6 +119,10 @@ services:
--zmq-pub tcp://0.0.0.0:18083
--disable-dns-checkpoints
--enable-dns-blocklist
--out-peers 32
--in-peers 16
--add-priority-node=nodes.hashvault.pro:18080
--add-priority-node=node.supportxmr.com:18080
--non-interactive
--p2p-bind-ip=0.0.0.0
--p2p-bind-port=18080
+4
View File
@@ -96,6 +96,10 @@ services:
--zmq-pub tcp://0.0.0.0:18083
--disable-dns-checkpoints
--enable-dns-blocklist
--out-peers 32
--in-peers 16
--add-priority-node=nodes.hashvault.pro:18080
--add-priority-node=node.supportxmr.com:18080
--non-interactive
--p2p-bind-ip=0.0.0.0
--p2p-bind-port=18080
+2 -1
View File
@@ -237,7 +237,8 @@ It's highly recommended to create a new wallet for mining because wallet address
<ul>
<li>Download the latest Monero <a href="https://www.getmonero.org/downloads/" target="_blank">release</a>
<li>[Optional] Open port <span>18080</span> (Monero p2p port) in your firewall to ensure better connectivity
<li>Run <span>./monerod --zmq-pub tcp://127.0.0.1:18083 --disable-dns-checkpoints --enable-dns-blocklist</span>
<li>Run <span>./monerod --zmq-pub tcp://127.0.0.1:18083 --out-peers 64 --in-peers 32 --add-priority-node=node.supportxmr.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --disable-dns-checkpoints --enable-dns-blocklist</span>
<li>If your network connection's upload bandwidth is less than 10 Mbit, use <span>--out-peers 16 --in-peers 8</span> instead.
<li>Wait until it's fully synchronized. If you didn't run Monero node before, it can take up to several days to synchronize (5-6 hours on a modern PC with fast SSD and fast Internet connection). You can add <span>--prune-blockchain</span> argument to the command line to run a pruned node (3-4 times less disk usage)
</ul></details>
+2 -1
View File
@@ -237,7 +237,8 @@ It's highly recommended to create a new wallet for mining because wallet address
<ul>
<li>Download the latest Monero <a href="https://www.getmonero.org/downloads/" target="_blank">release</a>
<li>[Optional] Open port <span>18080</span> (Monero p2p port) in your firewall to ensure better connectivity
<li>Run <span>./monerod --zmq-pub tcp://127.0.0.1:18083 --disable-dns-checkpoints --enable-dns-blocklist</span>
<li>Run <span>./monerod --zmq-pub tcp://127.0.0.1:18083 --out-peers 64 --in-peers 32 --add-priority-node=node.supportxmr.com:18080 --add-priority-node=nodes.hashvault.pro:18080 --disable-dns-checkpoints --enable-dns-blocklist</span>
<li>If your network connection's upload bandwidth is less than 10 Mbit, use <span>--out-peers 16 --in-peers 8</span> instead.
<li>Wait until it's fully synchronized. If you didn't run Monero node before, it can take up to several days to synchronize (5-6 hours on a modern PC with fast SSD and fast Internet connection). You can add <span>--prune-blockchain</span> argument to the command line to run a pruned node (3-4 times less disk usage)
</ul></details>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+132
View File
@@ -0,0 +1,132 @@
// Copyright (c) 2014-2022, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef _MSC_VER
#pragma warning(disable : 4514 4820)
#endif
#include "hardforks.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "blockchain.hardforks"
const hardfork_t mainnet_hard_forks[] = {
// version 1 from the start of the blockchain
{ 1, 1, 0, 1341378000 },
// version 2 starts from block 1009827, which is on or around the 20th of March, 2016. Fork time finalised on 2015-09-20. No fork voting occurs for the v2 fork.
{ 2, 1009827, 0, 1442763710 },
// version 3 starts from block 1141317, which is on or around the 24th of September, 2016. Fork time finalised on 2016-03-21.
{ 3, 1141317, 0, 1458558528 },
// version 4 starts from block 1220516, which is on or around the 5th of January, 2017. Fork time finalised on 2016-09-18.
{ 4, 1220516, 0, 1483574400 },
// version 5 starts from block 1288616, which is on or around the 15th of April, 2017. Fork time finalised on 2017-03-14.
{ 5, 1288616, 0, 1489520158 },
// version 6 starts from block 1400000, which is on or around the 16th of September, 2017. Fork time finalised on 2017-08-18.
{ 6, 1400000, 0, 1503046577 },
// version 7 starts from block 1546000, which is on or around the 6th of April, 2018. Fork time finalised on 2018-03-17.
{ 7, 1546000, 0, 1521303150 },
// version 8 starts from block 1685555, which is on or around the 18th of October, 2018. Fork time finalised on 2018-09-02.
{ 8, 1685555, 0, 1535889547 },
// version 9 starts from block 1686275, which is on or around the 19th of October, 2018. Fork time finalised on 2018-09-02.
{ 9, 1686275, 0, 1535889548 },
// version 10 starts from block 1788000, which is on or around the 9th of March, 2019. Fork time finalised on 2019-02-10.
{ 10, 1788000, 0, 1549792439 },
// version 11 starts from block 1788720, which is on or around the 10th of March, 2019. Fork time finalised on 2019-02-15.
{ 11, 1788720, 0, 1550225678 },
// version 12 starts from block 1978433, which is on or around the 30th of November, 2019. Fork time finalised on 2019-10-18.
{ 12, 1978433, 0, 1571419280 },
{ 13, 2210000, 0, 1598180817 },
{ 14, 2210720, 0, 1598180818 },
{ 15, 2688888, 0, 1656629117 },
{ 16, 2689608, 0, 1656629118 },
};
const size_t num_mainnet_hard_forks = sizeof(mainnet_hard_forks) / sizeof(mainnet_hard_forks[0]);
const uint64_t mainnet_hard_fork_version_1_till = 1009826;
const hardfork_t testnet_hard_forks[] = {
// version 1 from the start of the blockchain
{ 1, 1, 0, 1341378000 },
// version 2 starts from block 624634, which is on or around the 23rd of November, 2015. Fork time finalised on 2015-11-20. No fork voting occurs for the v2 fork.
{ 2, 624634, 0, 1445355000 },
// versions 3-5 were passed in rapid succession from September 18th, 2016
{ 3, 800500, 0, 1472415034 },
{ 4, 801219, 0, 1472415035 },
{ 5, 802660, 0, 1472415036 + 86400*180 }, // add 5 months on testnet to shut the update warning up since there's a large gap to v6
{ 6, 971400, 0, 1501709789 },
{ 7, 1057027, 0, 1512211236 },
{ 8, 1057058, 0, 1533211200 },
{ 9, 1057778, 0, 1533297600 },
{ 10, 1154318, 0, 1550153694 },
{ 11, 1155038, 0, 1550225678 },
{ 12, 1308737, 0, 1569582000 },
{ 13, 1543939, 0, 1599069376 },
{ 14, 1544659, 0, 1599069377 },
{ 15, 1982800, 0, 1652727000 },
{ 16, 1983520, 0, 1652813400 },
};
const size_t num_testnet_hard_forks = sizeof(testnet_hard_forks) / sizeof(testnet_hard_forks[0]);
const uint64_t testnet_hard_fork_version_1_till = 624633;
const hardfork_t stagenet_hard_forks[] = {
// version 1 from the start of the blockchain
{ 1, 1, 0, 1341378000 },
// versions 2-7 in rapid succession from March 13th, 2018
{ 2, 32000, 0, 1521000000 },
{ 3, 33000, 0, 1521120000 },
{ 4, 34000, 0, 1521240000 },
{ 5, 35000, 0, 1521360000 },
{ 6, 36000, 0, 1521480000 },
{ 7, 37000, 0, 1521600000 },
{ 8, 176456, 0, 1537821770 },
{ 9, 177176, 0, 1537821771 },
{ 10, 269000, 0, 1550153694 },
{ 11, 269720, 0, 1550225678 },
{ 12, 454721, 0, 1571419280 },
{ 13, 675405, 0, 1598180817 },
{ 14, 676125, 0, 1598180818 },
{ 15, 1151000, 0, 1656629117 },
{ 16, 1151720, 0, 1656629118 },
};
const size_t num_stagenet_hard_forks = sizeof(stagenet_hard_forks) / sizeof(stagenet_hard_forks[0]);
+52
View File
@@ -0,0 +1,52 @@
// Copyright (c) 2014-2022, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once
#include <stdint.h>
#include <time.h>
struct hardfork_t
{
uint8_t version;
uint64_t height;
uint8_t threshold;
time_t time;
hardfork_t(uint8_t version, uint64_t height, uint8_t threshold, time_t time): version(version), height(height), threshold(threshold), time(time) {}
};
extern const hardfork_t mainnet_hard_forks[];
extern const uint64_t mainnet_hard_fork_version_1_till;
extern const size_t num_mainnet_hard_forks;
extern const hardfork_t testnet_hard_forks[];
extern const uint64_t testnet_hard_fork_version_1_till;
extern const size_t num_testnet_hard_forks;
extern const hardfork_t stagenet_hard_forks[];
extern const size_t num_stagenet_hard_forks;
+9 -3
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -145,7 +145,7 @@ struct BlockCache::Impl : public nocopy_nomove
#else
// Not implemented on other platforms
void flush() {}
void flush() { m_data = nullptr; }
#endif
uint8_t* m_data = nullptr;
@@ -155,6 +155,7 @@ BlockCache::BlockCache()
: m_impl(new Impl())
, m_flushRunning(0)
, m_storeIndex(0)
, m_loadingStarted(0)
{
}
@@ -188,6 +189,11 @@ void BlockCache::load_all(SideChain& side_chain, P2PServer& server)
return;
}
// Can be only called once
if (m_loadingStarted.exchange(1)) {
return;
}
LOGINFO(1, "loading cached blocks");
PoolBlock block;
@@ -212,7 +218,7 @@ void BlockCache::load_all(SideChain& side_chain, P2PServer& server)
void BlockCache::flush()
{
if (m_flushRunning.exchange(1) == 0) {
if (m_flushRunning.exchange(1)) {
m_impl->flush();
m_flushRunning.store(0);
}
+2 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,6 +38,7 @@ private:
Impl* m_impl;
std::atomic<uint32_t> m_flushRunning;
std::atomic<uint32_t> m_storeIndex;
std::atomic<uint32_t> m_loadingStarted;
};
} // namespace p2pool
+17 -8
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
* Portions Copyright (c) 2012-2013 The Cryptonote developers
* Portions Copyright (c) 2014-2021 The Monero Project
* Portions Copyright (c) 2021 XMRig <https://github.com/xmrig>
@@ -260,7 +260,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, Wallet
m_sidechain->fill_sidechain_data(*m_poolBlockTemplate, miner_wallet, m_txkeySec, m_shares);
// Only choose transactions that were received 10 or more seconds ago
// Only choose transactions that were received 10 or more seconds ago, or high fee (>= 0.006 XMR) transactions
size_t total_mempool_transactions;
{
m_mempoolTxs.clear();
@@ -272,7 +272,7 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, Wallet
const uint64_t cur_time = seconds_since_epoch();
for (auto& it : mempool.m_transactions) {
if (cur_time >= it.second.time_received + 10) {
if ((cur_time >= it.second.time_received + 10) || (it.second.fee >= HIGH_FEE_VALUE)) {
m_mempoolTxs.emplace_back(it.second);
}
}
@@ -1115,7 +1115,7 @@ std::vector<uint8_t> BlockTemplate::get_block_template_blob(uint32_t template_id
return m_blockTemplateBlob;
}
void BlockTemplate::submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce)
bool BlockTemplate::submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce)
{
WriteLock lock(m_lock);
@@ -1154,17 +1154,26 @@ void BlockTemplate::submit_sidechain_block(uint32_t template_id, uint32_t nonce,
m_poolBlockTemplate->m_verified = true;
if (!m_sidechain->block_seen(*m_poolBlockTemplate)) {
m_poolBlockTemplate->m_wantBroadcast = true;
m_sidechain->add_block(*m_poolBlockTemplate);
const bool result = m_sidechain->add_block(*m_poolBlockTemplate);
if (!result) {
LOGWARN(3, "failed to submit a share: add_block failed for template id " << template_id);
}
return result;
}
return;
const PoolBlock* b = m_poolBlockTemplate;
LOGWARN(3, "failed to submit a share: template id " << template_id << ", block " << b->m_sidechainId << ", nonce = " << b->m_nonce << ", extra_nonce = " << b->m_extraNonce << " was already added before");
return false;
}
BlockTemplate* old = m_oldTemplates[template_id % array_size(&BlockTemplate::m_oldTemplates)];
if (old && (template_id == old->m_templateId)) {
old->submit_sidechain_block(template_id, nonce, extra_nonce);
return;
return old->submit_sidechain_block(template_id, nonce, extra_nonce);
}
LOGWARN(3, "failed to submit a share: template id " << template_id << " is too old/out of range, current template id is " << m_templateId);
return false;
}
} // namespace p2pool
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -53,7 +53,7 @@ public:
FORCEINLINE uint64_t height() const { return m_height; }
FORCEINLINE difficulty_type difficulty() const { return m_difficulty; }
void submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
bool submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
FORCEINLINE const std::vector<MinerShare>& shares() const { return m_shares; }
FORCEINLINE const PoolBlock* pool_block_template() const { return m_poolBlockTemplate; }
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
#ifdef _MSC_VER
#pragma warning(disable : 4005 4061 4324 4365 4464 4625 4626 4668 4710 4711 4804 4820 5039 5045 5220 5246)
#pragma warning(disable : 4005 4061 4324 4365 4464 4619 4625 4626 4668 4710 4711 4804 4820 5039 5045 5220 5246 5264)
#define FORCEINLINE __forceinline
#define NOINLINE __declspec(noinline)
#define LIKELY(expression) expression
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021 hyc <https://github.com/hyc>
*
* This program is free software: you can redistribute it and/or modify
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+13 -2
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,6 +21,11 @@
#include <ctime>
#include <fstream>
#include <thread>
#include <stdlib.h>
#ifdef _MSC_VER
#pragma warning(disable : 4996)
#endif
static constexpr char log_category_prefix[] = "Log ";
static constexpr char log_file_name[] = "p2pool.log";
@@ -86,6 +91,11 @@ public:
}
#endif
const char* no_color = getenv("NO_COLOR");
if (no_color && *no_color) {
CONSOLE_COLORS = false;
}
LOGINFO(0, "started");
if (!m_logFile.is_open()) {
@@ -160,7 +170,7 @@ private:
#define putenv _putenv
#endif
const uint32_t N = std::max(std::min(std::thread::hardware_concurrency(), 4U), 8U);
const uint32_t N = std::min(std::max(std::thread::hardware_concurrency(), 4U), 8U);
char buf[40] = {};
log::Stream s(buf);
@@ -321,6 +331,7 @@ static Worker worker;
NOINLINE Writer::Writer(Severity severity) : Stream(m_stackBuf)
{
m_stackBuf[BUF_SIZE] = '\0';
m_buf[0] = static_cast<char>(severity);
m_pos = 3;
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+3 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,6 +21,8 @@
namespace p2pool {
constexpr uint64_t HIGH_FEE_VALUE = 6000000000ULL;
class p2pool;
class Mempool : public nocopy_nomove
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -212,8 +212,8 @@ void Miner::run(WorkerData* data)
if (j.m_sidechainDiff.check_pow(h)) {
LOGINFO(0, log::Green() << "SHARE FOUND: mainchain height " << j.m_height << ", sidechain height " << j.m_sidechainHeight << ", diff " << j.m_sidechainDiff << ", worker thread " << data->m_index << '/' << data->m_count);
m_pool->submit_sidechain_block(j.m_templateId, j.m_nonce, j.m_extraNonce);
++m_sharesFound;
m_pool->submit_sidechain_block(j.m_templateId, j.m_nonce, j.m_extraNonce);
}
std::this_thread::yield();
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+59 -34
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -381,7 +381,7 @@ void P2PServer::send_peer_list_request(P2PClient* client, uint64_t cur_time)
const bool result = send(client,
[client](void* buf, size_t buf_size)
{
LOGINFO(5, "sending PEER_LIST_REQUEST to " << static_cast<char*>(client->m_addrString));
LOGINFO(6, "sending PEER_LIST_REQUEST to " << static_cast<char*>(client->m_addrString));
if (buf_size < SEND_BUF_MIN_SIZE) {
return 0;
@@ -959,21 +959,21 @@ void P2PServer::show_peers()
{
MutexLock lock(m_clientsListLock);
const uint64_t cur_time = seconds_since_epoch();
size_t n = 0;
for (P2PClient* client = static_cast<P2PClient*>(m_connectedClientsList->m_next); client != m_connectedClientsList; client = static_cast<P2PClient*>(client->m_next)) {
if (client->m_listenPort >= 0) {
char buf[32];
char buf[32] = {};
log::Stream s(buf);
if (client->m_P2PoolVersion) {
s << "\tv" << (client->m_P2PoolVersion >> 16) << '.' << (client->m_P2PoolVersion & 0xFFFF) << "\t\0";
}
else {
s << "\t \t\0";
if (client->m_SoftwareVersion) {
s << client->software_name() << " v" << (client->m_SoftwareVersion >> 16) << '.' << (client->m_SoftwareVersion & 0xFFFF);
}
LOGINFO(0, (client->m_isIncoming ? "I\t" : "O\t")
<< log::pad_right(client->m_pingTime, 4) << " ms\t"
<< static_cast<const char*>(buf)
<< log::pad_right(log::Duration(cur_time - client->m_connectedTime), 16) << '\t'
<< log::pad_right(client->m_pingTime, 4) << " ms\t\t"
<< log::pad_right(static_cast<const char*>(buf), 20) << '\t'
<< log::pad_right(client->m_broadcastMaxHeight, 10) << '\t'
<< static_cast<char*>(client->m_addrString));
++n;
}
@@ -1135,7 +1135,7 @@ void P2PServer::download_missing_blocks()
});
if (result) {
++client->m_blockPendingRequests;
client->m_blockPendingRequests.push_back(id);
}
}
}
@@ -1171,6 +1171,8 @@ void P2PServer::check_block_template()
P2PServer::P2PClient::P2PClient()
: m_peerId(0)
, m_connectedTime(0)
, m_broadcastMaxHeight(0)
, m_expectedMessage(MessageId::HANDSHAKE_CHALLENGE)
, m_handshakeChallenge(0)
, m_handshakeSolutionSent(false)
@@ -1183,10 +1185,9 @@ P2PServer::P2PClient::P2PClient()
, m_lastPeerListRequestTime{}
, m_peerListPendingRequests(0)
, m_protocolVersion(PROTOCOL_VERSION_1_0)
, m_P2PoolVersion(0)
, m_SoftwareVersion(0)
, m_SoftwareID(0)
, m_pingTime(-1)
, m_blockPendingRequests(0)
, m_chainTipBlockRequest(false)
, m_lastAlive(0)
, m_lastBroadcastTimestamp(0)
, m_lastBlockrequestTimestamp(0)
@@ -1218,6 +1219,8 @@ void P2PServer::P2PClient::reset()
Client::reset();
m_peerId = 0;
m_connectedTime = 0;
m_broadcastMaxHeight = 0;
m_expectedMessage = MessageId::HANDSHAKE_CHALLENGE;
m_handshakeChallenge = 0;
m_handshakeSolutionSent = false;
@@ -1230,10 +1233,10 @@ void P2PServer::P2PClient::reset()
m_lastPeerListRequestTime = {};
m_peerListPendingRequests = 0;
m_protocolVersion = PROTOCOL_VERSION_1_0;
m_P2PoolVersion = 0;
m_SoftwareVersion = 0;
m_SoftwareID = 0;
m_pingTime = -1;
m_blockPendingRequests = 0;
m_chainTipBlockRequest = false;
m_blockPendingRequests.clear();
m_lastAlive = 0;
m_lastBroadcastTimestamp = 0;
m_lastBlockrequestTimestamp = 0;
@@ -1268,7 +1271,9 @@ bool P2PServer::P2PClient::on_connect()
}
}
m_lastAlive = seconds_since_epoch();
const uint64_t cur_time = seconds_since_epoch();
m_connectedTime = cur_time;
m_lastAlive = cur_time;
return send_handshake_challenge();
}
@@ -1392,7 +1397,7 @@ bool P2PServer::P2PClient::on_read(char* data, uint32_t size)
break;
case MessageId::BLOCK_RESPONSE:
if (m_blockPendingRequests <= 0) {
if (m_blockPendingRequests.empty()) {
LOGWARN(4, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " sent an unexpected BLOCK_RESPONSE");
ban(DEFAULT_BAN_TIME);
server->remove_peer_from_list(this);
@@ -1406,8 +1411,10 @@ bool P2PServer::P2PClient::on_read(char* data, uint32_t size)
if (bytes_left >= 1 + sizeof(uint32_t) + block_size) {
bytes_read = 1 + sizeof(uint32_t) + block_size;
--m_blockPendingRequests;
if (!on_block_response(buf + 1 + sizeof(uint32_t), block_size)) {
const hash expected_id = m_blockPendingRequests.front();
m_blockPendingRequests.pop_front();
if (!on_block_response(buf + 1 + sizeof(uint32_t), block_size, expected_id)) {
ban(DEFAULT_BAN_TIME);
server->remove_peer_from_list(this);
return false;
@@ -1437,7 +1444,7 @@ bool P2PServer::P2PClient::on_read(char* data, uint32_t size)
break;
case MessageId::PEER_LIST_REQUEST:
LOGINFO(5, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " sent PEER_LIST_REQUEST");
LOGINFO(6, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " sent PEER_LIST_REQUEST");
if (bytes_left >= 1) {
bytes_read = 1;
@@ -1457,7 +1464,7 @@ bool P2PServer::P2PClient::on_read(char* data, uint32_t size)
return false;
}
LOGINFO(5, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " sent PEER_LIST_RESPONSE");
LOGINFO(6, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " sent PEER_LIST_RESPONSE");
if (bytes_left >= 2) {
const uint32_t num_peers = buf[1];
@@ -1845,8 +1852,7 @@ void P2PServer::P2PClient::on_after_handshake(uint8_t* &p)
memcpy(p, empty.h, HASH_SIZE);
p += HASH_SIZE;
++m_blockPendingRequests;
m_chainTipBlockRequest = true;
m_blockPendingRequests.push_back(empty);
m_lastBroadcastTimestamp = seconds_since_epoch();
}
@@ -1908,7 +1914,7 @@ bool P2PServer::P2PClient::on_block_request(const uint8_t* buf)
});
}
bool P2PServer::P2PClient::on_block_response(const uint8_t* buf, uint32_t size)
bool P2PServer::P2PClient::on_block_response(const uint8_t* buf, uint32_t size, const hash& expected_id)
{
if (!size) {
LOGINFO(5, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor() << " sent an empty block response");
@@ -1925,10 +1931,11 @@ bool P2PServer::P2PClient::on_block_response(const uint8_t* buf, uint32_t size)
return false;
}
if (m_chainTipBlockRequest) {
m_chainTipBlockRequest = false;
const PoolBlock* block = server->get_block();
const uint64_t peer_height = server->get_block()->m_txinGenHeight;
// Chain tip request
if (expected_id.empty()) {
const uint64_t peer_height = block->m_txinGenHeight;
const uint64_t our_height = server->m_pool->miner_data().height;
if (peer_height + 2 < our_height) {
@@ -1941,11 +1948,15 @@ bool P2PServer::P2PClient::on_block_response(const uint8_t* buf, uint32_t size)
server->send_peer_list_request(this, cur_time);
}
}
else if (block->m_sidechainId != expected_id) {
LOGWARN(3, "peer " << static_cast<char*>(m_addrString) << " sent a wrong block: expected " << expected_id << ", got " << block->m_sidechainId);
return false;
}
const SideChain& side_chain = server->m_pool->side_chain();
const uint64_t max_time_delta = side_chain.precalcFinished() ? (side_chain.block_time() * side_chain.chain_window_size() * 4) : 0;
return handle_incoming_block_async(server->get_block(), max_time_delta);
return handle_incoming_block_async(block, max_time_delta);
}
bool P2PServer::P2PClient::on_block_broadcast(const uint8_t* buf, uint32_t size, bool compact)
@@ -1967,6 +1978,7 @@ bool P2PServer::P2PClient::on_block_broadcast(const uint8_t* buf, uint32_t size,
const PoolBlock* block = server->get_block();
m_broadcastMaxHeight = std::max(m_broadcastMaxHeight, block->m_sidechainHeight);
m_broadcastedHashes[m_broadcastedHashesIndex.fetch_add(1) % array_size(&P2PClient::m_broadcastedHashes)] = block->m_sidechainId;
MinerData miner_data = server->m_pool->miner_data();
@@ -2080,7 +2092,7 @@ bool P2PServer::P2PClient::on_peer_list_request(const uint8_t*)
return server->send(this,
[this, &peers, num_selected_peers](void* buf, size_t buf_size) -> size_t
{
LOGINFO(5, "sending PEER_LIST_RESPONSE to " << static_cast<char*>(m_addrString));
LOGINFO(6, "sending PEER_LIST_RESPONSE to " << static_cast<char*>(m_addrString));
if (buf_size < SEND_BUF_MIN_SIZE + 2 + num_selected_peers * 19) {
return 0;
@@ -2140,10 +2152,11 @@ bool P2PServer::P2PClient::on_peer_list_response(const uint8_t* buf)
// Check for protocol version message
if ((*reinterpret_cast<uint32_t*>(ip.data + 12) == 0xFFFFFFFFU) && (port == 0xFFFF)) {
m_protocolVersion = *reinterpret_cast<uint32_t*>(ip.data);
m_P2PoolVersion = *reinterpret_cast<uint32_t*>(ip.data + 4);
m_SoftwareVersion = *reinterpret_cast<uint32_t*>(ip.data + 4);
m_SoftwareID = *reinterpret_cast<uint32_t*>(ip.data + 8);
LOGINFO(5, "peer " << log::Gray() << static_cast<char*>(m_addrString) << log::NoColor()
<< " supports protocol version " << (m_protocolVersion >> 16) << '.' << (m_protocolVersion & 0xFFFF)
<< ", runs P2Pool version " << (m_P2PoolVersion >> 16) << '.' << (m_P2PoolVersion & 0xFFFF)
<< ", runs " << software_name() << " v" << (m_SoftwareVersion >> 16) << '.' << (m_SoftwareVersion & 0xFFFF)
);
}
continue;
@@ -2342,7 +2355,19 @@ void P2PServer::P2PClient::post_handle_incoming_block(const uint32_t reset_count
return;
}
++m_blockPendingRequests;
m_blockPendingRequests.push_back(id);
}
}
const char* P2PServer::P2PClient::software_name() const
{
switch (m_SoftwareID) {
case 0:
return "P2Pool";
case 0x624F6F47UL:
return "GoObserver";
default:
return "Unknown";
}
}
+11 -5
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
#pragma once
#include "tcp_server.h"
#include <list>
namespace p2pool {
@@ -99,7 +100,7 @@ public:
void on_after_handshake(uint8_t* &p);
bool on_listen_port(const uint8_t* buf);
bool on_block_request(const uint8_t* buf);
bool on_block_response(const uint8_t* buf, uint32_t size);
bool on_block_response(const uint8_t* buf, uint32_t size, const hash& expected_id);
bool on_block_broadcast(const uint8_t* buf, uint32_t size, bool compact);
bool on_peer_list_request(const uint8_t* buf);
bool on_peer_list_response(const uint8_t* buf);
@@ -110,7 +111,12 @@ public:
bool is_good() const { return m_handshakeComplete && !m_handshakeInvalid && (m_listenPort >= 0); }
const char* software_name() const;
uint64_t m_peerId;
uint64_t m_connectedTime;
uint64_t m_broadcastMaxHeight;
MessageId m_expectedMessage;
uint64_t m_handshakeChallenge;
bool m_handshakeSolutionSent;
@@ -125,12 +131,12 @@ public:
int m_peerListPendingRequests;
uint32_t m_protocolVersion;
uint32_t m_P2PoolVersion;
uint32_t m_SoftwareVersion;
uint32_t m_SoftwareID;
int64_t m_pingTime;
int m_blockPendingRequests;
bool m_chainTipBlockRequest;
std::list<hash> m_blockPendingRequests;
uint64_t m_lastAlive;
uint64_t m_lastBroadcastTimestamp;
+29 -12
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -244,6 +244,11 @@ void p2pool::handle_tx(TxMempoolData& tx)
", weight = " << log::Gray() << tx.weight << log::NoColor() <<
", fee = " << log::Gray() << static_cast<double>(tx.fee) / 1e6 << " um");
if (tx.fee >= HIGH_FEE_VALUE) {
LOGINFO(4, "high fee tx received: " << log::LightBlue() << tx.id << log::NoColor() << ", " << log::XMRAmount(tx.fee) << " - updating block template");
update_block_template_async();
}
#if TEST_MEMPOOL_PICKING_ALGORITHM
m_blockTemplate->update(miner_data(), *m_mempool, &m_params->m_wallet);
#endif
@@ -405,10 +410,16 @@ void p2pool::handle_chain_main(ChainMain& data, const char* extra)
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);
const Wallet& w = params().m_wallet;
const uint64_t payout = block->get_payout(w);
if (payout) {
LOGINFO(0, log::LightCyan() << "You received a payout of " << log::LightGreen() << log::XMRAmount(payout) << log::LightCyan() << " in block " << log::LightGreen() << data.height);
LOGINFO(0, log::LightCyan() << "Your wallet " << log::LightGreen() << w << log::LightCyan() << " got a payout of " << log::LightGreen() << log::XMRAmount(payout) << log::LightCyan() << " in block " << log::LightGreen() << data.height);
}
else {
LOGINFO(0, log::LightCyan() << "Your wallet " << log::LightYellow() << w << log::LightCyan() << " didn't get a payout in block " << log::LightYellow() << data.height << log::LightCyan() << " because you had no shares in PPLNS window");
}
api_update_block_found(&data, block);
}
else {
@@ -569,8 +580,8 @@ void p2pool::submit_block() const
const char* error_msg = nullptr;
auto it = doc.FindMember("message");
if (it != doc.MemberEnd() && it->value.IsString()) {
auto it = err.FindMember("message");
if (it != err.MemberEnd() && it->value.IsString()) {
error_msg = it->value.GetString();
}
@@ -608,10 +619,10 @@ void p2pool::submit_block() const
});
}
void p2pool::submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce)
bool p2pool::submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce)
{
LOGINFO(3, "submit_sidechain_block: template id = " << template_id << ", nonce = " << nonce << ", extra_nonce = " << extra_nonce);
m_blockTemplate->submit_sidechain_block(template_id, nonce, extra_nonce);
return m_blockTemplate->submit_sidechain_block(template_id, nonce, extra_nonce);
}
void p2pool::update_block_template_async(bool is_alternative_block)
@@ -621,7 +632,9 @@ void p2pool::update_block_template_async(bool is_alternative_block)
return;
}
m_isAlternativeBlock = is_alternative_block;
if (is_alternative_block) {
m_isAlternativeBlock = true;
}
const int err = uv_async_send(&m_blockTemplateAsync);
if (err) {
@@ -717,6 +730,7 @@ void p2pool::download_block_headers(uint64_t current_height)
}
#endif
api_update_network_stats();
get_miner_data();
}
}
else {
@@ -986,6 +1000,9 @@ void p2pool::parse_get_version_rpc(const char* data, size_t size)
void p2pool::get_miner_data()
{
if (m_getMinerDataPending) {
return;
}
m_getMinerDataPending = true;
JSONRPCRequest::call(m_params->m_host, m_params->m_rpcPort, "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"get_miner_data\"}", m_params->m_rpcLogin, m_params->m_socks5Proxy,
@@ -1065,7 +1082,9 @@ void p2pool::parse_get_miner_data_rpc(const char* data, size_t size)
}
handle_miner_data(minerData);
download_block_headers(minerData.height);
if (m_serversStarted.load() == 0) {
download_block_headers(minerData.height);
}
}
bool p2pool::parse_block_header(const char* data, size_t size, ChainMain& c)
@@ -1503,9 +1522,7 @@ void p2pool::restart_zmq()
return;
}
if (!m_getMinerDataPending) {
get_miner_data();
}
get_miner_data();
delete m_ZMQReader;
m_ZMQReader = nullptr;
+3 -3
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,7 +35,7 @@ class p2pool_api;
class ZMQReader;
struct PoolBlock;
class p2pool : public MinerCallbackHandler
class p2pool : public MinerCallbackHandler, public nocopy_nomove
{
public:
p2pool(int argc, char* argv[]);
@@ -76,7 +76,7 @@ public:
void submit_block_async(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
void submit_block_async(std::vector<uint8_t>&& blob);
void submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
bool submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
void update_block_template_async(bool is_alternative_block = false);
void update_block_template();
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+3 -3
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -105,12 +105,12 @@ Params::Params(int argc, char* argv[])
ok = true;
}
if ((strcmp(argv[i], "--out-peers") == 0) && (i + 1 < argc)) {
if ((!strcmp(argv[i], "--out-peers") || !strcmp(argv[i], "--outpeers")) && (i + 1 < argc)) {
m_maxOutgoingPeers = std::min(std::max(strtoul(argv[++i], nullptr, 10), 10UL), 450UL);
ok = true;
}
if ((strcmp(argv[i], "--in-peers") == 0) && (i + 1 < argc)) {
if ((!strcmp(argv[i], "--in-peers") || !strcmp(argv[i], "--inpeers")) && (i + 1 < argc)) {
m_maxIncomingPeers = std::min(std::max(strtoul(argv[++i], nullptr, 10), 10UL), 450UL);
ok = true;
}
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+2 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -84,6 +84,7 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
EXPECT_BYTE(TXIN_GEN);
READ_VARINT(m_txinGenHeight);
if (m_majorVersion != sidechain.network_major_version(m_txinGenHeight)) return __LINE__;
if (unlock_height != m_txinGenHeight + MINER_REWARD_UNLOCK_TIME) return __LINE__;
std::vector<uint8_t> outputs_blob;
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+44 -6
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,6 +33,7 @@
#include "params.h"
#include "json_parsers.h"
#include "crypto.h"
#include "hardforks/hardforks.h"
#include <rapidjson/document.h>
#include <rapidjson/istreamwrapper.h>
#include <fstream>
@@ -566,9 +567,13 @@ bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_
data = m_watchBlock;
block_found = true;
const uint64_t payout = block.get_payout(m_pool->params().m_wallet);
const Wallet& w = m_pool->params().m_wallet;
const uint64_t payout = block.get_payout(w);
if (payout) {
LOGINFO(0, log::LightCyan() << "You received a payout of " << log::LightGreen() << log::XMRAmount(payout) << log::LightCyan() << " in block " << log::LightGreen() << data.height);
LOGINFO(0, log::LightCyan() << "Your wallet " << log::LightGreen() << w << log::LightCyan() << " got a payout of " << log::LightGreen() << log::XMRAmount(payout) << log::LightCyan() << " in block " << log::LightGreen() << data.height);
}
else {
LOGINFO(0, log::LightCyan() << "Your wallet " << log::LightYellow() << w << log::LightCyan() << " didn't get a payout in block " << log::LightYellow() << data.height << log::LightCyan() << " because you had no shares in PPLNS window");
}
}
}
@@ -581,7 +586,7 @@ bool SideChain::add_external_block(PoolBlock& block, std::vector<hash>& missing_
return true;
}
void SideChain::add_block(const PoolBlock& block)
bool SideChain::add_block(const PoolBlock& block)
{
LOGINFO(3, "add_block: height = " << block.m_sidechainHeight <<
", id = " << block.m_sidechainId <<
@@ -615,7 +620,7 @@ void SideChain::add_block(const PoolBlock& block)
);
delete new_block;
return;
return false;
}
m_blocksByHeight[new_block->m_sidechainHeight].push_back(new_block);
@@ -638,6 +643,8 @@ void SideChain::add_block(const PoolBlock& block)
else {
verify_loop(new_block);
}
return true;
}
PoolBlock* SideChain::find_block(const hash& id) const
@@ -1040,6 +1047,37 @@ double SideChain::get_reward_share(const Wallet& w) const
return total_reward ? (static_cast<double>(reward) / static_cast<double>(total_reward)) : 0.0;
}
uint64_t SideChain::network_major_version(uint64_t height) const
{
const hardfork_t* hard_forks;
size_t num_hard_forks;
switch (m_networkType)
{
case NetworkType::Mainnet:
default:
hard_forks = mainnet_hard_forks;
num_hard_forks = num_mainnet_hard_forks;
break;
case NetworkType::Testnet:
hard_forks = testnet_hard_forks;
num_hard_forks = num_testnet_hard_forks;
break;
case NetworkType::Stagenet:
hard_forks = stagenet_hard_forks;
num_hard_forks = num_stagenet_hard_forks;
break;
}
uint64_t result = 1;
for (size_t i = 1; (i < num_hard_forks) && (height >= hard_forks[i].height); ++i) {
result = hard_forks[i].version;
}
return result;
}
difficulty_type SideChain::total_hashes() const
{
const PoolBlock* tip = m_chainTip;
@@ -1988,7 +2026,7 @@ bool SideChain::load_config(const std::string& filename)
return true;
}
bool SideChain::check_config()
bool SideChain::check_config() const
{
if (m_poolName.empty()) {
LOGERR(1, "name can't be empty");
+4 -3
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -47,7 +47,7 @@ public:
bool block_seen(const PoolBlock& block);
void unsee_block(const PoolBlock& block);
bool add_external_block(PoolBlock& block, std::vector<hash>& missing_blocks);
void add_block(const PoolBlock& block);
bool add_block(const PoolBlock& block);
void get_missing_blocks(std::vector<hash>& missing_blocks) const;
PoolBlock* find_block(const hash& id) const;
@@ -65,6 +65,7 @@ public:
const std::vector<uint8_t>& consensus_id() const { return m_consensusId; }
uint64_t chain_window_size() const { return m_chainWindowSize; }
NetworkType network_type() const { return m_networkType; }
uint64_t network_major_version(uint64_t height) const;
FORCEINLINE difficulty_type difficulty() const { ReadLock lock(m_curDifficultyLock); return m_curDifficulty; }
difficulty_type total_hashes() const;
uint64_t block_time() const { return m_targetBlockTime; }
@@ -98,7 +99,7 @@ private:
void prune_old_blocks();
bool load_config(const std::string& filename);
bool check_config();
bool check_config() const;
mutable uv_rwlock_t m_sidechainLock;
std::atomic<PoolBlock*> m_chainTip;
+58 -21
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -54,6 +54,7 @@ StratumServer::StratumServer(p2pool* pool)
, m_hashrateDataTail_24h(0)
, m_cumulativeFoundSharesDiff(0.0)
, m_totalFoundShares(0)
, m_totalFailedShares(0)
, m_apiLastUpdateTime(0)
{
// Diffuse the initial state in case it has low quality
@@ -420,6 +421,13 @@ bool StratumServer::on_submit(StratumClient* client, uint32_t id, const char* jo
share->m_hashes = (target > 1) ? udiv128(1, 0, target, &rem) : 1;
share->m_highEnoughDifficulty = sidechain_diff.check_pow(resultHash);
// Don't count shares that were found during sync
const SideChain& side_chain = m_pool->side_chain();
const PoolBlock* tip = side_chain.chainTip();
if (tip && (sidechain_height + side_chain.chain_window_size() < tip->m_sidechainHeight)) {
share->m_highEnoughDifficulty = false;
}
update_auto_diff(client, share->m_timestamp, share->m_hashes);
// If this share is below sidechain difficulty, process it in this thread because it'll be quick
@@ -513,10 +521,13 @@ void StratumServer::show_workers()
void StratumServer::reset_share_counters()
{
WriteLock lock(m_hashrateDataLock);
m_cumulativeHashes = 0;
m_cumulativeHashesAtLastShare = 0;
m_cumulativeFoundSharesDiff = 0.0;
m_totalFoundShares = 0;
m_totalFailedShares = 0;
}
void StratumServer::print_stratum_status() const
@@ -525,6 +536,8 @@ void StratumServer::print_stratum_status() const
int64_t dt_15m, dt_1h, dt_24h;
uint64_t hashes_since_last_share;
double average_effort;
uint32_t shares_found, shares_failed;
{
ReadLock lock(m_hashrateDataLock);
@@ -546,16 +559,25 @@ void StratumServer::print_stratum_status() const
hashes_24h = head.m_cumulativeHashes - tail_24h.m_cumulativeHashes;
dt_24h = static_cast<int64_t>(head.m_timestamp - tail_24h.m_timestamp);
average_effort = 0.0;
const double diff = m_cumulativeFoundSharesDiff;
if (diff > 0.0) {
average_effort = static_cast<double>(m_cumulativeHashesAtLastShare) * 100.0 / diff;
}
shares_found = m_totalFoundShares;
shares_failed = m_totalFailedShares;
}
const uint64_t hashrate_15m = (dt_15m > 0) ? (hashes_15m / dt_15m) : 0;
const uint64_t hashrate_1h = (dt_1h > 0) ? (hashes_1h / dt_1h ) : 0;
const uint64_t hashrate_24h = (dt_24h > 0) ? (hashes_24h / dt_24h) : 0;
double average_effort = 0.0;
const double diff = m_cumulativeFoundSharesDiff;
if (diff > 0.0) {
average_effort = static_cast<double>(m_cumulativeHashesAtLastShare) * 100.0 / diff;
char shares_failed_buf[64] = {};
log::Stream s(shares_failed_buf);
if (shares_failed) {
s << log::Yellow() << "\nShares failed = " << shares_failed << log::NoColor();
}
LOGINFO(0, "status" <<
@@ -563,7 +585,7 @@ void StratumServer::print_stratum_status() const
"\nHashrate (1h est) = " << log::Hashrate(hashrate_1h) <<
"\nHashrate (24h est) = " << log::Hashrate(hashrate_24h) <<
"\nTotal hashes = " << total_hashes <<
"\nShares found = " << m_totalFoundShares <<
"\nShares found = " << shares_found << shares_failed_buf <<
"\nAverage effort = " << average_effort << '%' <<
"\nCurrent effort = " << static_cast<double>(hashes_since_last_share) * 100.0 / m_pool->side_chain().difficulty().to_double() << '%' <<
"\nConnections = " << m_numConnections.load() << " (" << m_numIncomingConnections.load() << " incoming)"
@@ -857,15 +879,26 @@ void StratumServer::on_share_found(uv_work_t* req)
client->m_score += GOOD_SHARE_POINTS;
const uint64_t n = server->m_cumulativeHashes + hashes;
const double diff = sidechain_difficulty.to_double();
share->m_effort = static_cast<double>(n - server->m_cumulativeHashesAtLastShare) * 100.0 / diff;
server->m_cumulativeHashesAtLastShare = n;
{
WriteLock lock(server->m_hashrateDataLock);
server->m_cumulativeFoundSharesDiff += diff;
++server->m_totalFoundShares;
const uint64_t n = server->m_cumulativeHashes + hashes;
share->m_effort = static_cast<double>(n - server->m_cumulativeHashesAtLastShare) * 100.0 / diff;
server->m_cumulativeHashesAtLastShare = n;
pool->submit_sidechain_block(share->m_templateId, share->m_nonce, share->m_extraNonce);
server->m_cumulativeFoundSharesDiff += diff;
++server->m_totalFoundShares;
}
if (!pool->submit_sidechain_block(share->m_templateId, share->m_nonce, share->m_extraNonce)) {
WriteLock lock(server->m_hashrateDataLock);
if (server->m_totalFoundShares > 0) {
--server->m_totalFoundShares;
++server->m_totalFailedShares;
}
}
}
// Send the response to miner
@@ -1185,6 +1218,8 @@ void StratumServer::api_update_local_stats(uint64_t timestamp)
int64_t dt_15m, dt_1h, dt_24h;
uint64_t hashes_since_last_share;
double average_effort;
uint32_t shares_found, shares_failed;
{
ReadLock lock(m_hashrateDataLock);
@@ -1206,33 +1241,35 @@ void StratumServer::api_update_local_stats(uint64_t timestamp)
hashes_24h = head.m_cumulativeHashes - tail_24h.m_cumulativeHashes;
dt_24h = static_cast<int64_t>(head.m_timestamp - tail_24h.m_timestamp);
average_effort = 0.0;
const double diff = m_cumulativeFoundSharesDiff;
if (diff > 0.0) {
average_effort = static_cast<double>(m_cumulativeHashesAtLastShare) * 100.0 / diff;
}
shares_found = m_totalFoundShares;
shares_failed = m_totalFailedShares;
}
const uint64_t hashrate_15m = (dt_15m > 0) ? (hashes_15m / dt_15m) : 0;
const uint64_t hashrate_1h = (dt_1h > 0) ? (hashes_1h / dt_1h ) : 0;
const uint64_t hashrate_24h = (dt_24h > 0) ? (hashes_24h / dt_24h) : 0;
double average_effort = 0.0;
const double diff = m_cumulativeFoundSharesDiff;
if (diff > 0.0) {
average_effort = static_cast<double>(m_cumulativeHashesAtLastShare) * 100.0 / diff;
}
int shares_found = m_totalFoundShares;
double current_effort = static_cast<double>(hashes_since_last_share) * 100.0 / m_pool->side_chain().difficulty().to_double();
int connections = m_numConnections;
int incoming_connections = m_numIncomingConnections;
m_pool->api()->set(p2pool_api::Category::LOCAL, "stats",
[hashrate_15m, hashrate_1h, hashrate_24h, total_hashes, shares_found, average_effort, current_effort, connections, incoming_connections](log::Stream& s)
[hashrate_15m, hashrate_1h, hashrate_24h, total_hashes, shares_found, shares_failed, average_effort, current_effort, connections, incoming_connections](log::Stream& s)
{
s << "{\"hashrate_15m\":" << hashrate_15m
<< ",\"hashrate_1h\":" << hashrate_1h
<< ",\"hashrate_24h\":" << hashrate_24h
<< ",\"total_hashes\":" << total_hashes
<< ",\"shares_found\":" << shares_found
<< ",\"shares_failed\":" << shares_failed
<< ",\"average_effort\":" << average_effort
<< ",\"current_effort\":" << current_effort
<< ",\"connections\":" << connections
+2 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -176,6 +176,7 @@ private:
double m_cumulativeFoundSharesDiff;
uint32_t m_totalFoundShares;
uint32_t m_totalFailedShares;
uint64_t m_apiLastUpdateTime;
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+3 -3
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
#include <map>
#include <thread>
#ifndef _WIN32
#if !defined(_WIN32) && defined(HAVE_SCHED)
#include <sched.h>
#endif
@@ -66,7 +66,7 @@ void make_thread_background()
SetThreadPriorityBoost(GetCurrentThread(), true);
SetThreadPriority(GetCurrentThread(), THREAD_MODE_BACKGROUND_BEGIN);
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE);
#elif !defined(__APPLE__) && !defined(__FreeBSD__)
#elif defined(HAVE_SCHED)
sched_param param;
param.sched_priority = 0;
if (sched_setscheduler(0, SCHED_IDLE, &param) != 0) {
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,7 +35,7 @@
namespace p2pool {
#define P2POOL_VERSION_MAJOR 2
#define P2POOL_VERSION_MINOR 6
#define P2POOL_VERSION_MINOR 7
extern const char* VERSION;
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
* Portions Copyright (c) 2012-2013 The Cryptonote developers
* Portions Copyright (c) 2014-2021 The Monero Project
* Portions Copyright (c) 2021 XMRig <https://github.com/xmrig>
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* This file is part of the Monero P2Pool <https://github.com/SChernykh/p2pool>
* Copyright (c) 2021-2022 SChernykh <https://github.com/SChernykh>
* Copyright (c) 2021-2023 SChernykh <https://github.com/SChernykh>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
+1
View File
@@ -33,6 +33,7 @@ set(SOURCES
src/wallet_tests.cpp
../external/src/cryptonote/crypto-ops-data.c
../external/src/cryptonote/crypto-ops.c
../external/src/hardforks/hardforks.cpp
../src/block_cache.cpp
../src/block_template.cpp
../src/console_commands.cpp