From 8e7c742e89ec3eabcc0733299ee3bbecf28baf86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 31 May 2017 09:59:41 +0200 Subject: [PATCH] BlockHash: Drop BlockDataType option --- libethcore/BlockInfo.cpp | 4 ++-- libethcore/BlockInfo.h | 18 ++++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/libethcore/BlockInfo.cpp b/libethcore/BlockInfo.cpp index b05f766dc..7eecbd982 100644 --- a/libethcore/BlockInfo.cpp +++ b/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); } diff --git a/libethcore/BlockInfo.h b/libethcore/BlockInfo.h index 7c05bfc8d..a8c36740e 100644 --- a/libethcore/BlockInfo.h +++ b/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.