mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin into serialize
Conflicts: src/LedgerFormats.cpp src/SerializedLedger.cpp src/Version.h Merge with master
This commit is contained in:
44
js/serializer.js
Normal file
44
js/serializer.js
Normal file
@@ -0,0 +1,44 @@
|
||||
//
|
||||
|
||||
var serializer = {};
|
||||
|
||||
serializer.addUInt16 = function(value) {
|
||||
switch (typeof value) {
|
||||
case 'string':
|
||||
addUInt16(value.charCodeAt(0));
|
||||
break;
|
||||
|
||||
case 'integer':
|
||||
for (i = 16/8; i; i -=1) {
|
||||
raw.push(value & 255);
|
||||
value >>= 8;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw 'UNEXPECTED_TYPE';
|
||||
}
|
||||
};
|
||||
|
||||
serializer.addUInt160 = function(value) {
|
||||
switch (typeof value) {
|
||||
case 'array':
|
||||
raw.concat(value);
|
||||
break;
|
||||
|
||||
case 'integer':
|
||||
for (i = 160/8; i; i -=1) {
|
||||
raw.push(value & 255);
|
||||
value >>= 8;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw 'UNEXPECTED_TYPE';
|
||||
}
|
||||
};
|
||||
|
||||
serializer.getSHA512Half = function() {
|
||||
};
|
||||
|
||||
// vim:ts=4
|
||||
@@ -73,7 +73,8 @@ void Application::run()
|
||||
boost::thread auxThread(boost::bind(&boost::asio::io_service::run, &mAuxService));
|
||||
auxThread.detach();
|
||||
|
||||
mSNTPClient.init(theConfig.SNTP_SERVERS);
|
||||
if (!theConfig.RUN_STANDALONE)
|
||||
mSNTPClient.init(theConfig.SNTP_SERVERS);
|
||||
|
||||
//
|
||||
// Construct databases.
|
||||
|
||||
@@ -394,10 +394,9 @@ void LedgerEntrySet::calcRawMeta(Serializer& s)
|
||||
|
||||
if (origNode->getType() == ltRIPPLE_STATE)
|
||||
{
|
||||
metaNode.addAccount(TMSLowID, origNode->getIValueFieldAccount(sfLowID));
|
||||
metaNode.addAccount(TMSHighID, origNode->getIValueFieldAccount(sfHighID));
|
||||
metaNode.addAccount(TMSLowID, NewcoinAddress::createAccountID(origNode->getIValueFieldAmount(sfLowLimit).getIssuer()));
|
||||
metaNode.addAccount(TMSHighID, NewcoinAddress::createAccountID(origNode->getIValueFieldAmount(sfHighLimit).getIssuer()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (origNode->getType() == ltOFFER)
|
||||
@@ -1011,6 +1010,7 @@ STAmount LedgerEntrySet::rippleTransferFee(const uint160& uSenderID, const uint1
|
||||
void LedgerEntrySet::rippleCredit(const uint160& uSenderID, const uint160& uReceiverID, const STAmount& saAmount, bool bCheckIssuer)
|
||||
{
|
||||
uint160 uIssuerID = saAmount.getIssuer();
|
||||
uint160 uCurrencyID = saAmount.getCurrency();
|
||||
|
||||
assert(!bCheckIssuer || uSenderID == uIssuerID || uReceiverID == uIssuerID);
|
||||
|
||||
@@ -1024,14 +1024,16 @@ void LedgerEntrySet::rippleCredit(const uint160& uSenderID, const uint160& uRece
|
||||
|
||||
STAmount saBalance = saAmount;
|
||||
|
||||
saBalance.setIssuer(ACCOUNT_ONE);
|
||||
|
||||
sleRippleState = entryCreate(ltRIPPLE_STATE, uIndex);
|
||||
|
||||
if (!bFlipped)
|
||||
saBalance.negate();
|
||||
|
||||
sleRippleState->setIFieldAmount(sfBalance, saBalance);
|
||||
sleRippleState->setIFieldAccount(bFlipped ? sfHighID : sfLowID, uSenderID);
|
||||
sleRippleState->setIFieldAccount(bFlipped ? sfLowID : sfHighID, uReceiverID);
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfHighLimit : sfLowLimit, STAmount(uCurrencyID, uSenderID));
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfLowLimit : sfHighLimit, STAmount(uCurrencyID, uReceiverID));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -81,9 +81,7 @@ LedgerEntryFormat LedgerFormats[]=
|
||||
{ sfLedgerEntryType,SOE_REQUIRED },
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfBalance, SOE_REQUIRED },
|
||||
{ sfLowID, SOE_REQUIRED },
|
||||
{ sfLowLimit, SOE_REQUIRED },
|
||||
{ sfHighID, SOE_REQUIRED },
|
||||
{ sfHighLimit, SOE_REQUIRED },
|
||||
{ sfLastTxnID, SOE_REQUIRED },
|
||||
{ sfLastTxnSeq, SOE_REQUIRED },
|
||||
|
||||
@@ -2540,7 +2540,7 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params
|
||||
{ "data_fetch", &RPCServer::doDataFetch, 1, 1, true },
|
||||
{ "data_store", &RPCServer::doDataStore, 2, 2, true },
|
||||
{ "ledger", &RPCServer::doLedger, 0, 2, false, optNetwork },
|
||||
{ "logrotate", &RPCServer::doLogRotate, 0, 0, false, optCurrent },
|
||||
{ "logrotate", &RPCServer::doLogRotate, 0, 0, true, 0 },
|
||||
{ "nickname_info", &RPCServer::doNicknameInfo, 1, 1, false, optCurrent },
|
||||
{ "nickname_set", &RPCServer::doNicknameSet, 2, 3, false, optCurrent },
|
||||
{ "offer_create", &RPCServer::doOfferCreate, 9, 10, false, optCurrent },
|
||||
|
||||
@@ -7,12 +7,12 @@ RippleState::RippleState(SerializedLedgerEntry::pointer ledgerEntry) :
|
||||
{
|
||||
if (!mLedgerEntry || mLedgerEntry->getType() != ltRIPPLE_STATE) return;
|
||||
|
||||
mLowID = mLedgerEntry->getIValueFieldAccount(sfLowID);
|
||||
mHighID = mLedgerEntry->getIValueFieldAccount(sfHighID);
|
||||
|
||||
mLowLimit = mLedgerEntry->getIValueFieldAmount(sfLowLimit);
|
||||
mHighLimit = mLedgerEntry->getIValueFieldAmount(sfHighLimit);
|
||||
|
||||
mLowID = NewcoinAddress::createAccountID(mLowLimit.getIssuer());
|
||||
mHighID = NewcoinAddress::createAccountID(mHighLimit.getIssuer());
|
||||
|
||||
mLowQualityIn = mLedgerEntry->getIFieldU32(sfLowQualityIn);
|
||||
mLowQualityOut = mLedgerEntry->getIFieldU32(sfLowQualityOut);
|
||||
|
||||
|
||||
@@ -118,12 +118,12 @@ NewcoinAddress SerializedLedgerEntry::getOwner()
|
||||
|
||||
NewcoinAddress SerializedLedgerEntry::getFirstOwner()
|
||||
{
|
||||
return getValueFieldAccount(sfLowID);
|
||||
return NewcoinAddress::createAccountID(getIValueFieldAmount(sfLowLimit).getIssuer());
|
||||
}
|
||||
|
||||
NewcoinAddress SerializedLedgerEntry::getSecondOwner()
|
||||
{
|
||||
return getValueFieldAccount(sfHighID);
|
||||
return NewcoinAddress::createAccountID(getIValueFieldAmount(sfHighLimit).getIssuer());
|
||||
}
|
||||
|
||||
std::vector<uint256> SerializedLedgerEntry::getOwners()
|
||||
@@ -134,12 +134,21 @@ std::vector<uint256> SerializedLedgerEntry::getOwners()
|
||||
for (int i = 0, fields = getCount(); i < fields; ++i)
|
||||
{
|
||||
int fc = getFieldSType(i).fieldCode;
|
||||
if ((fc == sfAccount.fieldCode) || (fc == sfLowID.fieldCode) || (fc == sfHighID.fieldCode))
|
||||
if ((fc == sfAccount.fieldCode) || (fc == sfOwner.fieldCode))
|
||||
{
|
||||
const STAccount* entry = dynamic_cast<const STAccount *>(peekAtPIndex(i));
|
||||
if ((entry != NULL) && entry->getValueH160(account))
|
||||
owners.push_back(Ledger::getAccountRootIndex(account));
|
||||
}
|
||||
if ((fc == sfLowLimit.fieldCode) || (fs == sfHighLimit.fieldCode))
|
||||
{
|
||||
const STAmount* entry = dynamic_cast<const STAmount *>(peekAtPIndex(i));
|
||||
if ((entry != NULL))
|
||||
{
|
||||
uint160 issuer = entry->getIssuer();
|
||||
if (issuer.isNonZero())
|
||||
owners.push_back(Ledger::getAccountRootIndex(issuer));
|
||||
}
|
||||
}
|
||||
|
||||
return owners;
|
||||
|
||||
@@ -246,13 +246,13 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
||||
|
||||
if (!uDstAccountID)
|
||||
{
|
||||
Log(lsINFO) << "doCreditSet: Invalid transaction: Destination account not specifed.";
|
||||
Log(lsINFO) << "doCreditSet: Malformed transaction: Destination account not specifed.";
|
||||
|
||||
return temDST_NEEDED;
|
||||
}
|
||||
else if (mTxnAccountID == uDstAccountID)
|
||||
{
|
||||
Log(lsINFO) << "doCreditSet: Invalid transaction: Can not extend credit to self.";
|
||||
Log(lsINFO) << "doCreditSet: Malformed transaction: Can not extend credit to self.";
|
||||
|
||||
return temDST_IS_SRC;
|
||||
}
|
||||
@@ -275,6 +275,13 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
||||
const uint160 uCurrencyID = saLimitAmount.getCurrency();
|
||||
bool bDelIndex = false;
|
||||
|
||||
if (bLimitAmount && saLimitAmount.getIssuer() != mTxnAccountID)
|
||||
{
|
||||
Log(lsINFO) << "doCreditSet: Malformed transaction: issuer must be signer";
|
||||
|
||||
return temBAD_ISSUER;
|
||||
}
|
||||
|
||||
SLE::pointer sleRippleState = entryCache(ltRIPPLE_STATE, Ledger::getRippleStateIndex(mTxnAccountID, uDstAccountID, uCurrencyID));
|
||||
if (sleRippleState)
|
||||
{
|
||||
@@ -283,8 +290,8 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
||||
if (!saLimitAmount)
|
||||
{
|
||||
// Zeroing line.
|
||||
uint160 uLowID = sleRippleState->getIValueFieldAccount(sfLowID).getAccountID();
|
||||
uint160 uHighID = sleRippleState->getIValueFieldAccount(sfHighID).getAccountID();
|
||||
uint160 uLowID = sleRippleState->getIValueFieldAmount(sfLowLimit).getIssuer();
|
||||
uint160 uHighID = sleRippleState->getIValueFieldAmount(sfHighLimit).getIssuer();
|
||||
bool bLow = uLowID == uSrcAccountID;
|
||||
bool bHigh = uLowID == uDstAccountID;
|
||||
bool bBalanceZero = !sleRippleState->getIValueFieldAmount(sfBalance);
|
||||
@@ -306,7 +313,7 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
||||
if (!bDelIndex)
|
||||
{
|
||||
if (bLimitAmount)
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfHighLimit: sfLowLimit , saLimitAmount);
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfHighLimit: sfLowLimit, saLimitAmount);
|
||||
|
||||
if (!bQualityIn)
|
||||
{
|
||||
@@ -355,9 +362,8 @@ TER TransactionEngine::doCreditSet(const SerializedTransaction& txn)
|
||||
|
||||
sleRippleState->setIFieldAmount(sfBalance, STAmount(uCurrencyID, ACCOUNT_ONE)); // Zero balance in currency.
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfHighLimit : sfLowLimit, saLimitAmount);
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfLowLimit : sfHighLimit, STAmount(uCurrencyID, ACCOUNT_ONE));
|
||||
sleRippleState->setIFieldAccount(bFlipped ? sfHighID : sfLowID, mTxnAccountID);
|
||||
sleRippleState->setIFieldAccount(bFlipped ? sfLowID : sfHighID, uDstAccountID);
|
||||
sleRippleState->setIFieldAmount(bFlipped ? sfLowLimit : sfHighLimit, STAmount(uCurrencyID, uDstAccountID));
|
||||
|
||||
if (uQualityIn)
|
||||
sleRippleState->setIFieldU32(bFlipped ? sfHighQualityIn : sfLowQualityIn, uQualityIn);
|
||||
if (uQualityOut)
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
// Version we prefer to speak:
|
||||
#define PROTO_VERSION_MAJOR 1
|
||||
#define PROTO_VERSION_MINOR 0
|
||||
#define PROTO_VERSION_MINOR 1
|
||||
|
||||
// Version we will speak to:
|
||||
#define MIN_PROTO_MAJOR 1
|
||||
#define MIN_PROTO_MINOR 0
|
||||
#define MIN_PROTO_MINOR 1
|
||||
|
||||
#define MAKE_VERSION_INT(maj,min) ((maj << 16) | min)
|
||||
#define GET_VERSION_MAJOR(ver) (ver >> 16)
|
||||
|
||||
Reference in New Issue
Block a user