mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-11-16 15:57:39 +00:00
Added sanity checks for height and difficulty
This commit is contained in:
parent
a847baf331
commit
b3f562caab
2 changed files with 14 additions and 0 deletions
|
@ -53,6 +53,12 @@ static constexpr uint64_t MAX_BLOCK_SIZE = 128 * 1024 - 5;
|
|||
// 0.6 XMR
|
||||
static constexpr uint64_t BASE_BLOCK_REWARD = 600000000000ULL;
|
||||
|
||||
// 1000 years at 1 TH/s. It should be enough for any normal use.
|
||||
static constexpr difficulty_type MAX_CUMULATIVE_DIFFICULTY{ 13019633956666736640ULL, 1710ULL };
|
||||
|
||||
// 1000 years at 1 block/second. It should be enough for any normal use.
|
||||
static constexpr uint64_t MAX_SIDECHAIN_HEIGHT = 31556952000ULL;
|
||||
|
||||
struct DifficultyData
|
||||
{
|
||||
FORCEINLINE DifficultyData(uint64_t t, const difficulty_type& d) : m_timestamp(t), m_cumulativeDifficulty(d) {}
|
||||
|
|
|
@ -306,12 +306,20 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, const SideChain& si
|
|||
|
||||
READ_VARINT(m_sidechainHeight);
|
||||
|
||||
if (m_sidechainHeight > MAX_SIDECHAIN_HEIGHT) {
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
READ_VARINT(m_difficulty.lo);
|
||||
READ_VARINT(m_difficulty.hi);
|
||||
|
||||
READ_VARINT(m_cumulativeDifficulty.lo);
|
||||
READ_VARINT(m_cumulativeDifficulty.hi);
|
||||
|
||||
if (m_cumulativeDifficulty > MAX_CUMULATIVE_DIFFICULTY) {
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
READ_BUF(m_sidechainExtraBuf, sizeof(m_sidechainExtraBuf));
|
||||
|
||||
#undef READ_BYTE
|
||||
|
|
Loading…
Reference in a new issue