Skip to content

Commit

Permalink
XNS -> XRP
Browse files Browse the repository at this point in the history
  • Loading branch information
jed committed Nov 4, 2012
1 parent f180da5 commit d023566
Show file tree
Hide file tree
Showing 19 changed files with 128 additions and 56 deletions.
18 changes: 18 additions & 0 deletions newcoin.vcxproj
Expand Up @@ -206,15 +206,20 @@
<ClInclude Include="src\ConnectionPool.h" />
<ClInclude Include="src\Contract.h" />
<ClInclude Include="src\Conversion.h" />
<ClInclude Include="src\FieldNames.h" />
<ClInclude Include="src\HashedObject.h" />
<ClInclude Include="src\HashPrefixes.h" />
<ClInclude Include="src\HttpReply.h" />
<ClInclude Include="src\HttpRequest.h" />
<ClInclude Include="src\HttpsClient.h" />
<ClInclude Include="src\InstanceCounter.h" />
<ClInclude Include="src\Interpreter.h" />
<ClInclude Include="src\JobQueue.h" />
<ClInclude Include="src\key.h" />
<ClInclude Include="src\Ledger.h" />
<ClInclude Include="src\LedgerAcquire.h" />
<ClInclude Include="src\LedgerConsensus.h" />
<ClInclude Include="src\LedgerEntrySet.h" />
<ClInclude Include="src\LedgerFormats.h" />
<ClInclude Include="src\LedgerHistory.h" />
<ClInclude Include="src\LedgerMaster.h" />
Expand All @@ -234,8 +239,12 @@
<ClInclude Include="src\Peer.h" />
<ClInclude Include="src\PeerDoor.h" />
<ClInclude Include="src\PubKeyCache.h" />
<ClInclude Include="src\RangeSet.h" />
<ClInclude Include="src\RequestParser.h" />
<ClInclude Include="src\rfc1751.h" />
<ClInclude Include="src\ripple.pb.h" />
<ClInclude Include="src\RippleAddress.h" />
<ClInclude Include="src\RippleCalc.h" />
<ClInclude Include="src\RippleLines.h" />
<ClInclude Include="src\RippleState.h" />
<ClInclude Include="src\RPC.h" />
Expand All @@ -251,19 +260,28 @@
<ClInclude Include="src\SerializedTransaction.h" />
<ClInclude Include="src\SerializedTypes.h" />
<ClInclude Include="src\SerializedValidation.h" />
<ClInclude Include="src\SerializeProto.h" />
<ClInclude Include="src\Serializer.h" />
<ClInclude Include="src\SHAMap.h" />
<ClInclude Include="src\SHAMapSync.h" />
<ClInclude Include="src\SNTPClient.h" />
<ClInclude Include="src\Suppression.h" />
<ClInclude Include="src\TaggedCache.h" />
<ClInclude Include="src\Transaction.h" />
<ClInclude Include="src\TransactionEngine.h" />
<ClInclude Include="src\TransactionErr.h" />
<ClInclude Include="src\TransactionFormats.h" />
<ClInclude Include="src\TransactionMaster.h" />
<ClInclude Include="src\TransactionMeta.h" />
<ClInclude Include="src\types.h" />
<ClInclude Include="src\uint256.h" />
<ClInclude Include="src\UniqueNodeList.h" />
<ClInclude Include="src\utils.h" />
<ClInclude Include="src\ValidationCollection.h" />
<ClInclude Include="src\Version.h" />
<ClInclude Include="src\Wallet.h" />
<ClInclude Include="src\WSConnection.h" />
<ClInclude Include="src\WSDoor.h" />
<ClInclude Include="src\WSHandler.h" />
<ClInclude Include="TimingService.h" />
<ClInclude Include="ExtendedTransaction.h" />
Expand Down
54 changes: 54 additions & 0 deletions newcoin.vcxproj.filters
Expand Up @@ -578,6 +578,60 @@
<ClInclude Include="src\WSHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\FieldNames.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\HashPrefixes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\InstanceCounter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\JobQueue.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\LedgerEntrySet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\RangeSet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\ripple.pb.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\RippleAddress.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\RippleCalc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\SerializeProto.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\SHAMapSync.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\SNTPClient.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\Suppression.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\TransactionErr.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\TransactionMeta.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\Version.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\WSConnection.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\WSDoor.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="wallet.xml" />
Expand Down
10 changes: 5 additions & 5 deletions src/Amount.cpp
Expand Up @@ -16,7 +16,7 @@ SETUP_LOG();

uint64 STAmount::uRateOne = STAmount::getRate(STAmount(1), STAmount(1));

// --> sCurrency: "", "XNS", or three letter ISO code.
// --> sCurrency: "", "XRP", or three letter ISO code.
bool STAmount::currencyFromString(uint160& uDstCurrency, const std::string& sCurrency)
{
bool bSuccess = true;
Expand Down Expand Up @@ -1365,19 +1365,19 @@ BOOST_AUTO_TEST_CASE( CustomCurrency_test )

if (STAmount::multiply(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 20), STAmount(3), CURRENCY_ONE, ACCOUNT_ONE).getText() != "60")
BOOST_FAIL("STAmount multiply fail");
if (STAmount::multiply(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 20), STAmount(3), uint160(), ACCOUNT_XNS).getText() != "60")
if (STAmount::multiply(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 20), STAmount(3), uint160(), ACCOUNT_XRP).getText() != "60")
BOOST_FAIL("STAmount multiply fail");
if (STAmount::multiply(STAmount(20), STAmount(3), CURRENCY_ONE, ACCOUNT_ONE).getText() != "60")
BOOST_FAIL("STAmount multiply fail");
if (STAmount::multiply(STAmount(20), STAmount(3), uint160(), ACCOUNT_XNS).getText() != "60")
if (STAmount::multiply(STAmount(20), STAmount(3), uint160(), ACCOUNT_XRP).getText() != "60")
BOOST_FAIL("STAmount multiply fail");
if (STAmount::divide(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount(3), CURRENCY_ONE, ACCOUNT_ONE).getText() != "20")
BOOST_FAIL("STAmount divide fail");
if (STAmount::divide(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount(3), uint160(), ACCOUNT_XNS).getText() != "20")
if (STAmount::divide(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount(3), uint160(), ACCOUNT_XRP).getText() != "20")
BOOST_FAIL("STAmount divide fail");
if (STAmount::divide(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount(CURRENCY_ONE, ACCOUNT_ONE, 3), CURRENCY_ONE, ACCOUNT_ONE).getText() != "20")
BOOST_FAIL("STAmount divide fail");
if (STAmount::divide(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount(CURRENCY_ONE, ACCOUNT_ONE, 3), uint160(), ACCOUNT_XNS).getText() != "20")
if (STAmount::divide(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount(CURRENCY_ONE, ACCOUNT_ONE, 3), uint160(), ACCOUNT_XRP).getText() != "20")
BOOST_FAIL("STAmount divide fail");

STAmount a1(CURRENCY_ONE, ACCOUNT_ONE, 60), a2 (CURRENCY_ONE, ACCOUNT_ONE, 10, -1);
Expand Down
2 changes: 1 addition & 1 deletion src/Config.cpp
Expand Up @@ -35,7 +35,7 @@
#define SECTION_VALIDATORS "validators"
#define SECTION_VALIDATORS_SITE "validators_site"

// Fees are in XNS.
// Fees are in XRP.
#define DEFAULT_FEE_DEFAULT 10
#define DEFAULT_FEE_ACCOUNT_CREATE 1000*SYSTEM_CURRENCY_PARTS
#define DEFAULT_FEE_NICKNAME_CREATE 1000
Expand Down
4 changes: 2 additions & 2 deletions src/Config.h
Expand Up @@ -10,9 +10,9 @@
#include <boost/filesystem.hpp>

#define SYSTEM_NAME "ripple"
#define SYSTEM_CURRENCY_CODE "XNS"
#define SYSTEM_CURRENCY_CODE "XRP"
#define SYSTEM_CURRENCY_PRECISION 6
#define SYSTEM_CURRENCY_CODE_RIPPLE "XNR"
#define SYSTEM_CURRENCY_CODE_RIPPLE "XRR"

#define SYSTEM_CURRENCY_GIFT 1000ull
#define SYSTEM_CURRENCY_USERS 100000000ull
Expand Down
4 changes: 2 additions & 2 deletions src/Interpreter.cpp
Expand Up @@ -46,7 +46,7 @@ Interpreter::Interpreter()
mFunctionTable[CANCEL_OP]=new SubOp();
mFunctionTable[BLOCK_OP]=new SubOp();
mFunctionTable[BLOCK_END_OP]=new SubOp();
mFunctionTable[SEND_XNS_OP]=new SendXNSOp();
mFunctionTable[SEND_XRP_OP]=new SendXRPOp();
/*
mFunctionTable[SEND_OP]=new SendOp();
mFunctionTable[REMOVE_CONTRACT_OP]=new SubOp();
Expand All @@ -63,7 +63,7 @@ Interpreter::Interpreter()
mFunctionTable[GET_LEDGER_TIME_OP]=new SubOp();
mFunctionTable[GET_LEDGER_NUM_OP]=new SubOp();
mFunctionTable[GET_RAND_FLOAT_OP]=new SubOp();
mFunctionTable[GET_XNS_ESCROWED_OP]=new SubOp();
mFunctionTable[GET_XRP_ESCROWED_OP]=new SubOp();
mFunctionTable[GET_RIPPLE_ESCROWED_OP]=new SubOp();
mFunctionTable[GET_RIPPLE_ESCROWED_CURRENCY_OP]=new SubOp();
mFunctionTable[GET_RIPPLE_ESCROWED_ISSUER]=new GetRippleEscrowedIssuerOp();
Expand Down
4 changes: 2 additions & 2 deletions src/Interpreter.h
Expand Up @@ -39,12 +39,12 @@ class Interpreter
STOP_OP, CANCEL_OP,

BLOCK_OP, BLOCK_END_OP,
SEND_XNS_OP,SEND_OP,REMOVE_CONTRACT_OP,FEE_OP,CHANGE_CONTRACT_OWNER_OP,
SEND_XRP_OP,SEND_OP,REMOVE_CONTRACT_OP,FEE_OP,CHANGE_CONTRACT_OWNER_OP,
STOP_REMOVE_OP,
SET_DATA_OP,GET_DATA_OP, GET_NUM_DATA_OP,
SET_REGISTER_OP,GET_REGISTER_OP,
GET_ISSUER_ID_OP, GET_OWNER_ID_OP, GET_LEDGER_TIME_OP, GET_LEDGER_NUM_OP, GET_RAND_FLOAT_OP,
GET_XNS_ESCROWED_OP, GET_RIPPLE_ESCROWED_OP, GET_RIPPLE_ESCROWED_CURRENCY_OP, GET_RIPPLE_ESCROWED_ISSUER,
GET_XRP_ESCROWED_OP, GET_RIPPLE_ESCROWED_OP, GET_RIPPLE_ESCROWED_CURRENCY_OP, GET_RIPPLE_ESCROWED_ISSUER,
GET_ACCEPT_DATA_OP, GET_ACCEPTOR_ID_OP, GET_CONTRACT_ID_OP,
NUM_OF_OPS };

Expand Down
2 changes: 1 addition & 1 deletion src/Ledger.cpp
Expand Up @@ -563,7 +563,7 @@ Json::Value Ledger::getJson(int options)
}
else
ledger["closed"] = false;
if (mTransactionMap && (full || ((options & LEDGER_JSON_DUMP_TXNS) != 0)))
if (mTransactionMap && (full || ((options & LEDGER_JSON_DUMP_TXRP) != 0)))
{
Json::Value txns(Json::arrayValue);
SHAMapTreeNode::TNType type;
Expand Down
2 changes: 1 addition & 1 deletion src/Ledger.h
Expand Up @@ -35,7 +35,7 @@ enum LedgerStateParms
lepERROR = 32, // error
};

#define LEDGER_JSON_DUMP_TXNS 0x10000000
#define LEDGER_JSON_DUMP_TXRP 0x10000000
#define LEDGER_JSON_DUMP_STATE 0x20000000
#define LEDGER_JSON_FULL 0x40000000

Expand Down
2 changes: 1 addition & 1 deletion src/LedgerConsensus.cpp
Expand Up @@ -1117,7 +1117,7 @@ void LedgerConsensus::accept(SHAMap::ref set)
{
Log(lsTRACE) << "newLCL";
Json::Value p;
newLCL->addJson(p, LEDGER_JSON_DUMP_TXNS | LEDGER_JSON_DUMP_STATE);
newLCL->addJson(p, LEDGER_JSON_DUMP_TXRP | LEDGER_JSON_DUMP_STATE);
Log(lsTRACE) << p;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Operation.h
Expand Up @@ -276,7 +276,7 @@ class JumpOp : public Operation
}
};

class SendXNSOp : public Operation
class SendXRPOp : public Operation
{
public:
bool work(Interpreter* interpreter)
Expand Down
4 changes: 2 additions & 2 deletions src/OrderBookDB.cpp
Expand Up @@ -20,8 +20,8 @@ OrderBookDB::OrderBookDB(Ledger::pointer ledger)
mKnownMap[book->getBookBase()]=true;

if(!book->getCurrencyIn())
{ // XNS
mXNSOrders.push_back(book);
{ // XRP
mXRPOrders.push_back(book);
}else
{
mIssuerMap[book->getIssuerIn()].push_back(book);
Expand Down
6 changes: 3 additions & 3 deletions src/OrderBookDB.h
Expand Up @@ -9,16 +9,16 @@ But for now it is probably faster to just generate it each time
class OrderBookDB
{
std::vector<OrderBook::pointer> mEmptyVector;
std::vector<OrderBook::pointer> mXNSOrders;
std::vector<OrderBook::pointer> mXRPOrders;
std::map<uint160, std::vector<OrderBook::pointer> > mIssuerMap;

std::map<uint256, bool > mKnownMap;

public:
OrderBookDB(Ledger::pointer ledger);

// return list of all orderbooks that want XNS
std::vector<OrderBook::pointer>& getXNSInBooks(){ return mXNSOrders; }
// return list of all orderbooks that want XRP
std::vector<OrderBook::pointer>& getXRPInBooks(){ return mXRPOrders; }
// return list of all orderbooks that want IssuerID
std::vector<OrderBook::pointer>& getBooks(const uint160& issuerID);
// return list of all orderbooks that want this issuerID and currencyID
Expand Down
20 changes: 10 additions & 10 deletions src/Pathfinder.cpp
Expand Up @@ -21,18 +21,18 @@ TODO: what is a good way to come up with multiple paths?
OrderDB:
getXNSOffers();
getXRPOffers();
// return list of all orderbooks that want XNS
// return list of all orderbooks that want XRP
// return list of all orderbooks that want IssuerID
// return list of all orderbooks that want this issuerID and currencyID
*/

/*
Test sending to XNS
Test XNS to XNS
Test sending to XRP
Test XRP to XRP
Test offer in middle
Test XNS to USD
Test XRP to USD
Test USD to EUR
*/

Expand Down Expand Up @@ -113,7 +113,7 @@ bool Pathfinder::findPaths(int maxSearchSteps, int maxPay, STPathSet& retPathSet
// found the destination

if (!ele.mCurrencyID) {
BOOST_FOREACH(OrderBook::pointer book,mOrderBook.getXNSInBooks())
BOOST_FOREACH(OrderBook::pointer book,mOrderBook.getXRPInBooks())
{
//if (!path.hasSeen(line->getAccountIDPeer().getAccountID()))
{
Expand Down Expand Up @@ -188,17 +188,17 @@ bool Pathfinder::checkComplete(STPathSet& retPathSet)


// get all the options from this accountID
// if source is XNS
// every offer that wants XNS
// if source is XRP
// every offer that wants XRP
// else
// every ripple line that starts with the source currency
// every offer that we can take that wants the source currency

void Pathfinder::addOptions(PathOption::pointer tail)
{
if(!tail->mCurrencyID)
{ // source XNS
BOOST_FOREACH(OrderBook::pointer book,mOrderBook.getXNSInBooks())
{ // source XRP
BOOST_FOREACH(OrderBook::pointer book,mOrderBook.getXRPInBooks())
{
PathOption::pointer pathOption(new PathOption(tail));

Expand Down

0 comments on commit d023566

Please sign in to comment.