diff --git a/src/Amount.cpp b/src/Amount.cpp index bdfd1ec0e5..8f7766ea90 100644 --- a/src/Amount.cpp +++ b/src/Amount.cpp @@ -219,17 +219,22 @@ void STAmount::add(Serializer& s) const if (mIsNative) { assert(mOffset == 0); - if (!mIsNegative) s.add64(mValue | cPosNative); - else s.add64(mValue); - return; + if (!mIsNegative) + s.add64(mValue | cPosNative); + else + s.add64(mValue); + } + else + { + if (isZero()) + s.add64(cNotNative); + else if (mIsNegative) // 512 = not native + s.add64(mValue | (static_cast(mOffset + 512 + 97) << (64 - 10))); + else // 256 = positive + s.add64(mValue | (static_cast(mOffset + 512 + 256 + 97) << (64 - 10))); + + s.add160(mCurrency); } - if (isZero()) - s.add64(cNotNative); - else if (mIsNegative) // 512 = not native - s.add64(mValue | (static_cast(mOffset + 512 + 97) << (64 - 10))); - else // 256 = positive - s.add64(mValue | (static_cast(mOffset + 512 + 256 + 97) << (64 - 10))); - s.add160(mCurrency); } STAmount::STAmount(const char* name, int64 value) : SerializedType(name), mOffset(0), mIsNative(true) @@ -763,20 +768,25 @@ STAmount convertToInternalAmount(uint64 displayAmount, uint64 totalNow, uint64 t return STAmount(name, muldiv(displayAmount, totalNow, totalInit)); } -STAmount STAmount::deSerialize(SerializerIterator& it) +STAmount STAmount::deserialize(SerializerIterator& it) { STAmount *s = construct(it); STAmount ret(*s); + delete s; + return ret; } static STAmount serdes(const STAmount &s) { Serializer ser; + s.add(ser); + SerializerIterator sit(ser); - return STAmount::deSerialize(sit); + + return STAmount::deserialize(sit); } diff --git a/src/RPCServer.cpp b/src/RPCServer.cpp index 6ef4e485a1..ccd7b66bda 100644 --- a/src/RPCServer.cpp +++ b/src/RPCServer.cpp @@ -406,21 +406,30 @@ Json::Value RPCServer::doAccountLines(Json::Value ¶ms) RippleState::pointer rsLine = mNetOps->getRippleState(uLedger, uNode); - rsLine->setViewAccount(naAccount); + if (rsLine) + { + rsLine->setViewAccount(naAccount); - naAccountPeer = rsLine->getAccountIDPeer(); - saBalance = rsLine->getBalance(); - saLimit = rsLine->getLimit(); - saLimitPeer = rsLine->getLimitPeer(); + naAccountPeer = rsLine->getAccountIDPeer(); + saBalance = rsLine->getBalance(); + saLimit = rsLine->getLimit(); + saLimitPeer = rsLine->getLimitPeer(); - Json::Value jPeer = Json::Value(Json::objectValue); + Json::Value jPeer = Json::Value(Json::objectValue); - jPeer["balance"] = saBalance.getText(); - jPeer["currency"] = saBalance.getCurrencyHuman(); - jPeer["limit"] = saLimit.getJson(0); - jPeer["limit_peer"] = saLimitPeer.getJson(0); + jPeer["node"] = uNode.ToString(); - jsonLines[naAccountPeer.humanAccountID()] = jPeer; + jPeer["balance"] = saBalance.getText(); + jPeer["currency"] = saBalance.getCurrencyHuman(); + jPeer["limit"] = saLimit.getJson(0); + jPeer["limit_peer"] = saLimitPeer.getJson(0); + + jsonLines[naAccountPeer.humanAccountID()] = jPeer; + } + else + { + std::cerr << "doAccountLines: Bad index: " << uNode.ToString() << std::endl; + } } } diff --git a/src/SerializedTypes.cpp b/src/SerializedTypes.cpp index 6b4170868b..276b13464d 100644 --- a/src/SerializedTypes.cpp +++ b/src/SerializedTypes.cpp @@ -186,10 +186,20 @@ STVector256* STVector256::construct(SerializerIterator& u, const char *name) { std::vector data = u.getVL(); std::vector value; + int count = data.size() / (256 / 8); value.reserve(count); - for(int i = 0; i < count; i++) - value.push_back(uint256(std::vector(&data[i], &data[i + (256 / 8)]))); + + unsigned int uStart = 0; + for (unsigned int i = 0; i != count; i++) + { + unsigned int uEnd = uStart+(256/8); + + value.push_back(uint256(std::vector(&data[uStart], &data[uEnd]))); + + uStart = uEnd; + } + return new STVector256(name, value); } diff --git a/src/SerializedTypes.h b/src/SerializedTypes.h index f9f08690f8..933168b64b 100644 --- a/src/SerializedTypes.h +++ b/src/SerializedTypes.h @@ -330,7 +330,7 @@ public: friend STAmount convertToInternalAmount(uint64 displayAmount, uint64 totalNow, uint64 totalInit, const char* name = NULL); - static STAmount deSerialize(SerializerIterator&); + static STAmount deserialize(SerializerIterator&); static bool currencyFromString(uint160& uDstCurrency, const std::string& sCurrency); }; diff --git a/src/TransactionEngine.cpp b/src/TransactionEngine.cpp index ba97bfa112..0d1ac5d171 100644 --- a/src/TransactionEngine.cpp +++ b/src/TransactionEngine.cpp @@ -8,7 +8,7 @@ typedef SerializedLedgerEntry SLE; -#define DIR_NODE_MAX 32 +#define DIR_NODE_MAX 1 // We return the uNodeDir so that on delete we can quickly know where the element is mentioned in the directory. TransactionEngineResult TransactionEngine::dirAdd( @@ -63,6 +63,10 @@ TransactionEngineResult TransactionEngine::dirAdd( { // Last node is not full, append. + std::cerr << "dirAdd: appending: PREV: " << svIndexes.peekValue()[0].ToString() << std::endl; + std::cerr << "dirAdd: appending: Node: " << strHex(uNodeDir) << std::endl; + std::cerr << "dirAdd: appending: Entry: " << uLedgerIndex.ToString() << std::endl; + svIndexes.peekValue().push_back(uLedgerIndex); sleNode->setIFieldV256(sfIndexes, svIndexes);