mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-01-08 19:59:30 +00:00
Use extra_nonce to signal hardfork readiness
This commit is contained in:
parent
4f2ad9a93c
commit
8e7df958b8
3 changed files with 18 additions and 4 deletions
|
@ -47,7 +47,7 @@ Miner::Miner(p2pool* pool, uint32_t threads)
|
|||
, m_jobIndex{ 0 }
|
||||
{
|
||||
std::random_device rd;
|
||||
m_extraNonce = static_cast<uint32_t>(rd());
|
||||
m_extraNonce = PoolBlock::signal_v2_readiness(static_cast<uint32_t>(rd()));
|
||||
|
||||
on_block(m_pool->block_template());
|
||||
|
||||
|
|
|
@ -152,12 +152,26 @@ struct PoolBlock
|
|||
// but P2Pool can switch to using only TXOUT_TO_TAGGED_KEY for miner payouts starting from v15
|
||||
FORCEINLINE uint8_t get_tx_type() const { return (m_majorVersion < HARDFORK_VIEW_TAGS_VERSION) ? TXOUT_TO_KEY : TXOUT_TO_TAGGED_KEY; }
|
||||
|
||||
static constexpr int VERSION2_TIMESTAMP = 1679173200;
|
||||
|
||||
// Signal hardfork readiness (only before the v2 hardfork)
|
||||
// TODO: remove this code after hardfork
|
||||
FORCEINLINE static uint32_t signal_v2_readiness(uint32_t extra_nonce)
|
||||
{
|
||||
if (time(nullptr) < PoolBlock::VERSION2_TIMESTAMP) {
|
||||
extra_nonce |= 0xFF000000UL;
|
||||
extra_nonce &= ~0x00100000UL;
|
||||
return extra_nonce;
|
||||
}
|
||||
return extra_nonce;
|
||||
}
|
||||
|
||||
FORCEINLINE int get_sidechain_version() const
|
||||
{
|
||||
// P2Pool forks to v2 at 2023-03-18 21:00 UTC
|
||||
// Different miners can have different timestamps,
|
||||
// so a temporary mix of v1 and v2 blocks is allowed
|
||||
return (m_timestamp >= 1679173200) ? 2 : 1;
|
||||
return (m_timestamp >= VERSION2_TIMESTAMP) ? 2 : 1;
|
||||
}
|
||||
|
||||
typedef std::array<uint8_t, HASH_SIZE + NONCE_SIZE + EXTRA_NONCE_SIZE> full_id;
|
||||
|
|
|
@ -60,7 +60,7 @@ StratumServer::StratumServer(p2pool* pool)
|
|||
// Diffuse the initial state in case it has low quality
|
||||
m_rng.discard(10000);
|
||||
|
||||
m_extraNonce = static_cast<uint32_t>(m_rng());
|
||||
m_extraNonce = PoolBlock::signal_v2_readiness(static_cast<uint32_t>(m_rng()));
|
||||
|
||||
m_hashrateData[0] = { seconds_since_epoch(), 0 };
|
||||
|
||||
|
@ -107,7 +107,7 @@ void StratumServer::on_block(const BlockTemplate& block)
|
|||
return;
|
||||
}
|
||||
|
||||
const uint32_t extra_nonce_start = static_cast<uint32_t>(get_random64());
|
||||
const uint32_t extra_nonce_start = PoolBlock::signal_v2_readiness(static_cast<uint32_t>(get_random64()));
|
||||
m_extraNonce.exchange(extra_nonce_start + num_connections);
|
||||
|
||||
BlobsData* blobs_data = new BlobsData{};
|
||||
|
|
Loading…
Reference in a new issue