|
|
@ -206,9 +206,11 @@ u256 BlockInfo::calculateDifficulty(BlockInfo const& _parent) const |
|
|
|
if (!parentHash) |
|
|
|
return (u256)c_genesisDifficulty; |
|
|
|
else |
|
|
|
return max<u256>(c_minimumDifficulty, timestamp >= _parent.timestamp + c_durationLimit ? _parent.difficulty - (_parent.difficulty / c_difficultyBoundDivisor) : (_parent.difficulty + (_parent.difficulty / c_difficultyBoundDivisor))); |
|
|
|
return max<u256>(2048, timestamp >= _parent.timestamp + (c_protocolVersion == 49 ? 5 : 8) ? _parent.difficulty - (_parent.difficulty / 2048) : (_parent.difficulty + (_parent.difficulty / 2048))); |
|
|
|
} |
|
|
|
|
|
|
|
template <class N> inline N diff(N const& _a, N const& _b) { return max(_a, _b) - min(_a, _b); } |
|
|
|
|
|
|
|
void BlockInfo::verifyParent(BlockInfo const& _parent) const |
|
|
|
{ |
|
|
|
// Check difficulty is correct given the two timestamps.
|
|
|
@ -219,8 +221,9 @@ void BlockInfo::verifyParent(BlockInfo const& _parent) const |
|
|
|
gasLimit > _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor) |
|
|
|
BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, _parent.gasLimit * (c_gasLimitBoundDivisor - 1) / c_gasLimitBoundDivisor, _parent.gasLimit * (c_gasLimitBoundDivisor + 1) / c_gasLimitBoundDivisor)); |
|
|
|
|
|
|
|
if (seedHash != calculateSeedHash(_parent)) |
|
|
|
BOOST_THROW_EXCEPTION(InvalidSeedHash()); |
|
|
|
if (diff(gasLimit, _parent.gasLimit) <= _parent.gasLimit / 1024) |
|
|
|
BOOST_THROW_EXCEPTION(InvalidGasLimit(gasLimit, calculateGasLimit(_parent), diff(gasLimit, _parent.gasLimit), _parent.gasLimit / 1024)); |
|
|
|
|
|
|
|
|
|
|
|
// Check timestamp is after previous timestamp.
|
|
|
|
if (parentHash) |
|
|
|