Browse Source

BlockHeader: Remove Strictness option

cl-refactor
Paweł Bylica 7 years ago
parent
commit
b0da7a8cb1
No known key found for this signature in database GPG Key ID: 7A0C037434FE77EF
  1. 9
      libethcore/BlockHeader.cpp
  2. 16
      libethcore/BlockHeader.h

9
libethcore/BlockHeader.cpp

@ -30,11 +30,10 @@ using namespace dev;
using namespace dev::eth;
BlockHeader::BlockHeader(bytesConstRef _block, Strictness _s, h256 const& _hashWith)
BlockHeader::BlockHeader(bytesConstRef _block)
{
RLP header = extractHeader(_block);
m_hash = _hashWith ? _hashWith : sha3(header.data());
populateFromHeader(header, _s);
populateFromHeader(header);
}
h256 const& BlockHeader::boundary() const
@ -76,7 +75,7 @@ RLP BlockHeader::extractHeader(bytesConstRef _block)
return header;
}
void BlockHeader::populateFromHeader(RLP const& _header, Strictness _s)
void BlockHeader::populateFromHeader(RLP const& _header)
{
int field = 0;
try
@ -104,6 +103,6 @@ void BlockHeader::populateFromHeader(RLP const& _header, Strictness _s)
if (m_number > ~(unsigned)0)
BOOST_THROW_EXCEPTION(InvalidNumber());
if (_s != CheckNothing && m_gasUsed > m_gasLimit)
if (m_gasUsed > m_gasLimit)
BOOST_THROW_EXCEPTION(TooMuchGasUsed() << RequirementError(bigint(m_gasLimit), bigint(m_gasUsed)));
}

16
libethcore/BlockHeader.h

@ -41,12 +41,6 @@ using Nonce = h64;
using BlockNumber = unsigned;
enum Strictness
{
CheckEverything,
IgnoreSeal,
CheckNothing
};
/** @brief Encapsulation of a block header.
* Class to contain all of a block header's data. It is able to parse a block header and populate
@ -75,8 +69,8 @@ public:
static const unsigned BasicFields = 13;
BlockHeader() = default;
explicit BlockHeader(bytesConstRef _data, Strictness _s = CheckEverything, h256 const& _hashWith = h256());
explicit BlockHeader(bytes const& _data, Strictness _s = CheckEverything, h256 const& _hashWith = h256()): BlockHeader(&_data, _s, _hashWith) {}
explicit BlockHeader(bytesConstRef _data);
explicit BlockHeader(bytes const& _data): BlockHeader(&_data) {}
static RLP extractHeader(bytesConstRef _block);
@ -124,17 +118,15 @@ public:
/// sha3 of the header only.
h256 const& hashWithout() const;
void noteDirty() const { m_hashWithout = m_boundary = m_hash = h256(); }
void noteDirty() const { m_hashWithout = m_boundary = h256(); }
h256 const& seedHash() const;
Nonce const& nonce() const { return m_nonce; }
private:
void populateFromHeader(RLP const& _header, Strictness _s = IgnoreSeal);
void populateFromHeader(RLP const& _header);
void streamRLPFields(RLPStream& _s) const;
mutable h256 m_hash; ///< SHA3 hash of the block header! Not serialised.
h256 m_parentHash;
h256 m_sha3Uncles;
Address m_coinbaseAddress;

Loading…
Cancel
Save