Work toward working directories.

This commit is contained in:
Arthur Britto
2012-05-30 23:18:57 -07:00
parent a333a2a6c7
commit 21d9140e4e
5 changed files with 60 additions and 27 deletions

View File

@@ -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<uint64>(mOffset + 512 + 97) << (64 - 10)));
else // 256 = positive
s.add64(mValue | (static_cast<uint64>(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<uint64>(mOffset + 512 + 97) << (64 - 10)));
else // 256 = positive
s.add64(mValue | (static_cast<uint64>(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);
}

View File

@@ -406,21 +406,30 @@ Json::Value RPCServer::doAccountLines(Json::Value &params)
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;
}
}
}

View File

@@ -186,10 +186,20 @@ STVector256* STVector256::construct(SerializerIterator& u, const char *name)
{
std::vector<unsigned char> data = u.getVL();
std::vector<uint256> value;
int count = data.size() / (256 / 8);
value.reserve(count);
for(int i = 0; i < count; i++)
value.push_back(uint256(std::vector<unsigned char>(&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<unsigned char>(&data[uStart], &data[uEnd])));
uStart = uEnd;
}
return new STVector256(name, value);
}

View File

@@ -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);
};

View File

@@ -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);