Browse Source

BlockHash: Drop BlockDataType option

cl-refactor
Paweł Bylica 8 years ago
parent
commit
8e7c742e89
No known key found for this signature in database GPG Key ID: 7A0C037434FE77EF
  1. 4
      libethcore/BlockInfo.cpp
  2. 18
      libethcore/BlockInfo.h

4
libethcore/BlockInfo.cpp

@ -38,9 +38,9 @@ BlockInfo::BlockInfo(): m_timestamp(Invalid256)
{
}
BlockInfo::BlockInfo(bytesConstRef _block, Strictness _s, h256 const& _hashWith, BlockDataType _bdt)
BlockInfo::BlockInfo(bytesConstRef _block, Strictness _s, h256 const& _hashWith)
{
RLP header = _bdt == BlockData ? extractHeader(_block) : RLP(_block);
RLP header = extractHeader(_block);
m_hash = _hashWith ? _hashWith : sha3(header.data());
populateFromHeader(header, _s);
}

18
libethcore/BlockInfo.h

@ -50,12 +50,6 @@ enum Strictness
CheckNothing
};
enum BlockDataType
{
HeaderData,
BlockData
};
DEV_SIMPLE_EXCEPTION(NoHashRecorded);
DEV_SIMPLE_EXCEPTION(GenesisBlockCannotBeCalculated);
@ -86,8 +80,8 @@ public:
static const unsigned BasicFields = 13;
BlockInfo();
explicit BlockInfo(bytesConstRef _data, Strictness _s = CheckEverything, h256 const& _hashWith = h256(), BlockDataType _bdt = BlockData);
explicit BlockInfo(bytes const& _data, Strictness _s = CheckEverything, h256 const& _hashWith = h256(), BlockDataType _bdt = BlockData): BlockInfo(&_data, _s, _hashWith, _bdt) {}
explicit BlockInfo(bytesConstRef _data, Strictness _s = CheckEverything, h256 const& _hashWith = h256());
explicit BlockInfo(bytes const& _data, Strictness _s = CheckEverything, h256 const& _hashWith = h256()): BlockInfo(&_data, _s, _hashWith) {}
static RLP extractHeader(bytesConstRef _block);
@ -171,14 +165,14 @@ class BlockHeaderPolished: public BlockInfoSub
public:
BlockHeaderPolished() {}
BlockHeaderPolished(BlockInfo const& _bi): BlockInfoSub(_bi) {}
explicit BlockHeaderPolished(bytes const& _data, Strictness _s = IgnoreSeal, h256 const& _h = h256(), BlockDataType _bdt = BlockData) { populate(&_data, _s, _h, _bdt); }
explicit BlockHeaderPolished(bytesConstRef _data, Strictness _s = IgnoreSeal, h256 const& _h = h256(), BlockDataType _bdt = BlockData) { populate(_data, _s, _h, _bdt); }
explicit BlockHeaderPolished(bytes const& _data, Strictness _s = IgnoreSeal, h256 const& _h = h256()) { populate(&_data, _s, _h); }
explicit BlockHeaderPolished(bytesConstRef _data, Strictness _s = IgnoreSeal, h256 const& _h = h256()) { populate(_data, _s, _h); }
// deprecated for public API - use constructor.
// TODO: make private.
void populate(bytesConstRef _data, Strictness _s, h256 const& _h = h256(), BlockDataType _bdt = BlockData)
void populate(bytesConstRef _data, Strictness _s, h256 const& _h = h256())
{
populateFromHeader(_bdt == BlockData ? BlockInfo::extractHeader(_data) : RLP(_data), _s, _h);
populateFromHeader(BlockInfo::extractHeader(_data), _s, _h);
}
// deprecated for public API - use constructor.

Loading…
Cancel
Save