Tidy SetHex* function calls & misc cleanups

* Renamed SetHexExact -> SetHexUnchecked
* Removed calls to SetHexUnchecked with empty strings
* Marked ledger class as final, as it calls virtuals in its ctor
This commit is contained in:
seelabs
2015-08-31 12:17:25 -04:00
committed by Nik Bougalis
parent b0e6be93ff
commit 7f5d273e53
2 changed files with 16 additions and 8 deletions

View File

@@ -626,7 +626,7 @@ std::tuple<Ledger::pointer, std::uint32_t, uint256>
loadLedgerHelper(std::string const& sqlSuffix)
{
Ledger::pointer ledger;
uint256 ledgerHash;
uint256 ledgerHash{};
std::uint32_t ledgerSeq{0};
auto db = getApp ().getLedgerDB ().checkoutDb ();
@@ -665,11 +665,15 @@ loadLedgerHelper(std::string const& sqlSuffix)
ledgerSeq =
rangeCheckedCast<std::uint32_t>(ledgerSeq64.value_or (0));
uint256 prevHash, accountHash, transHash;
ledgerHash.SetHexExact (sLedgerHash.value_or(""));
prevHash.SetHexExact (sPrevHash.value_or(""));
accountHash.SetHexExact (sAccountHash.value_or(""));
transHash.SetHexExact (sTransHash.value_or(""));
uint256 prevHash{}, accountHash{}, transHash{};
if (sLedgerHash)
ledgerHash.SetHexExact (*sLedgerHash);
if (sPrevHash)
prevHash.SetHexExact (*sPrevHash);
if (sAccountHash)
accountHash.SetHexExact (*sAccountHash);
if (sTransHash)
transHash.SetHexExact (*sTransHash);
bool loaded = false;
ledger = std::make_shared<Ledger>(prevHash,
@@ -818,7 +822,10 @@ Ledger::getHashesByIndex (std::uint32_t minSeq, std::uint32_t maxSeq)
std::pair<uint256, uint256>& hashes =
ret[rangeCheckedCast<std::uint32_t>(ls)];
hashes.first.SetHexExact (lh);
hashes.second.SetHexExact (ph.value_or (""));
if (ph)
hashes.second.SetHexExact (*ph);
else
hashes.second.zero ();
if (!ph)
{
WriteLog (lsWARNING, Ledger)