diff --git a/src/cpp/ripple/Ledger.cpp b/src/cpp/ripple/Ledger.cpp index bb1da54cef..3db595c5aa 100644 --- a/src/cpp/ripple/Ledger.cpp +++ b/src/cpp/ripple/Ledger.cpp @@ -94,19 +94,19 @@ Ledger::Ledger(bool /* dummy */, Ledger& prevLedger) : zeroFees(); } -Ledger::Ledger(const std::vector& rawLedger) : +Ledger::Ledger(const std::vector& rawLedger, bool hasPrefix) : mClosed(false), mValidHash(false), mAccepted(false), mImmutable(true) { Serializer s(rawLedger); - setRaw(s); + setRaw(s, hasPrefix); zeroFees(); } -Ledger::Ledger(const std::string& rawLedger) : +Ledger::Ledger(const std::string& rawLedger, bool hasPrefix) : mClosed(false), mValidHash(false), mAccepted(false), mImmutable(true) { Serializer s(rawLedger); - setRaw(s); + setRaw(s, hasPrefix); zeroFees(); } @@ -127,9 +127,10 @@ void Ledger::updateHash() mValidHash = true; } -void Ledger::setRaw(Serializer &s) +void Ledger::setRaw(Serializer &s, bool hasPrefix) { SerializerIterator sit(s); + if (hasPrefix) sit.get32(); mLedgerSeq = sit.get32(); mTotCoins = sit.get64(); mParentHash = sit.get256(); diff --git a/src/cpp/ripple/Ledger.h b/src/cpp/ripple/Ledger.h index b9cf05892b..27fad106c1 100644 --- a/src/cpp/ripple/Ledger.h +++ b/src/cpp/ripple/Ledger.h @@ -109,9 +109,8 @@ public: uint64 totCoins, uint32 closeTime, uint32 parentCloseTime, int closeFlags, int closeResolution, uint32 ledgerSeq); // used for database ledgers - Ledger(const std::vector& rawLedger); - - Ledger(const std::string& rawLedger); + Ledger(const std::vector& rawLedger, bool hasPrefix); + Ledger(const std::string& rawLedger, bool hasPrefix); Ledger(bool dummy, Ledger& previous); // ledger after this one @@ -132,7 +131,7 @@ public: // ledger signature operations void addRaw(Serializer &s) const; - void setRaw(Serializer& s); + void setRaw(Serializer& s, bool hasPrefix); uint256 getHash(); const uint256& getParentHash() const { return mParentHash; } diff --git a/src/cpp/ripple/LedgerAcquire.cpp b/src/cpp/ripple/LedgerAcquire.cpp index 29a2aad708..55c539be1b 100644 --- a/src/cpp/ripple/LedgerAcquire.cpp +++ b/src/cpp/ripple/LedgerAcquire.cpp @@ -79,6 +79,7 @@ LedgerAcquire::LedgerAcquire(const uint256& hash) : PeerSet(hash, LEDGER_ACQUIRE #ifdef LA_DEBUG cLog(lsTRACE) << "Acquiring ledger " << mHash; #endif + tryLocal(); } bool LedgerAcquire::tryLocal() @@ -87,7 +88,7 @@ bool LedgerAcquire::tryLocal() if (!node) return false; - mLedger = boost::make_shared(strCopy(node->getData())); + mLedger = boost::make_shared(strCopy(node->getData()), true); assert(mLedger->getHash() == mHash); mHaveBase = true; @@ -254,7 +255,8 @@ void LedgerAcquire::trigger(Peer::ref peer, bool timer) mLedger->peekTransactionMap()->getMissingNodes(nodeIDs, nodeHashes, 128, &tFilter); if (nodeIDs.empty()) { - if (!mLedger->peekTransactionMap()->isValid()) mFailed = true; + if (!mLedger->peekTransactionMap()->isValid()) + mFailed = true; else { mHaveTransactions = true; @@ -294,7 +296,8 @@ void LedgerAcquire::trigger(Peer::ref peer, bool timer) mLedger->peekAccountStateMap()->getMissingNodes(nodeIDs, nodeHashes, 128, &aFilter); if (nodeIDs.empty()) { - if (!mLedger->peekAccountStateMap()->isValid()) mFailed = true; + if (!mLedger->peekAccountStateMap()->isValid()) + mFailed = true; else { mHaveState = true; @@ -367,14 +370,14 @@ int PeerSet::getPeerCount() const return ret; } -bool LedgerAcquire::takeBase(const std::string& data) +bool LedgerAcquire::takeBase(const std::string& data) // data must not have hash prefix { // Return value: true=normal, false=bad data #ifdef LA_DEBUG cLog(lsTRACE) << "got base acquiring ledger " << mHash; #endif boost::recursive_mutex::scoped_lock sl(mLock); if (mHaveBase) return true; - mLedger = boost::make_shared(data); + mLedger = boost::make_shared(data, false); if (mLedger->getHash() != mHash) { cLog(lsWARNING) << "Acquire hash mismatch";