Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
JoelKatz
2013-03-26 11:42:06 -07:00
10 changed files with 72 additions and 59 deletions

View File

@@ -1065,16 +1065,16 @@ void NetworkOPs::setMode(OperatingMode om)
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >
NetworkOPs::getAccountTxs(const RippleAddress& account, uint32 minLedger, uint32 maxLedger)
NetworkOPs::getAccountTxs(const RippleAddress& account, uint32 minLedger, uint32 maxLedger, bool bAdmin)
{ // can be called with no locks
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > ret;
std::string sql =
str(boost::format("SELECT AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta FROM "
boost::str(boost::format("SELECT AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta FROM "
"AccountTransactions INNER JOIN Transactions ON Transactions.TransID = AccountTransactions.TransID "
"WHERE Account = '%s' AND AccountTransactions.LedgerSeq <= '%u' AND AccountTransactions.LedgerSeq >= '%u' "
"ORDER BY AccountTransactions.LedgerSeq,AccountTransactions.TransID DESC LIMIT 200;")
% account.humanAccountID() % maxLedger % minLedger);
"ORDER BY AccountTransactions.LedgerSeq,AccountTransactions.TransID DESC%s;")
% account.humanAccountID() % maxLedger % minLedger % (bAdmin ? "" : " LIMIT 200"));
{
Database* db = theApp->getTxnDB()->getDB();
@@ -1103,15 +1103,15 @@ std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >
}
std::vector<NetworkOPs::txnMetaLedgerType> NetworkOPs::getAccountTxsB(
const RippleAddress& account, uint32 minLedger, uint32 maxLedger)
const RippleAddress& account, uint32 minLedger, uint32 maxLedger, bool bAdmin)
{ // can be called with no locks
std::vector< txnMetaLedgerType> ret;
std::string sql = str(boost::format("SELECT AccountTransactions.LedgerSeq,Status,RawTxn,TxnMeta FROM "
"AccountTransactions INNER JOIN Transactions ON Transactions.TransID = AccountTransactions.TransID "
"WHERE Account = '%s' AND AccountTransactions.LedgerSeq <= '%u' AND AccountTransactions.LedgerSeq >= '%u' "
"ORDER BY AccountTransactions.LedgerSeq,AccountTransactions.TransID DESC LIMIT 500;")
% account.humanAccountID() % maxLedger % minLedger);
"ORDER BY AccountTransactions.LedgerSeq,AccountTransactions.TransID DESC%s;")
% account.humanAccountID() % maxLedger % minLedger % (bAdmin ? "" : " LIMIT 500"));
{
Database* db = theApp->getTxnDB()->getDB();

View File

@@ -294,11 +294,11 @@ public:
// client information retrieval functions
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >
getAccountTxs(const RippleAddress& account, uint32 minLedger, uint32 maxLedger);
getAccountTxs(const RippleAddress& account, uint32 minLedger, uint32 maxLedger, bool bAdmin);
typedef boost::tuple<std::string, std::string, uint32> txnMetaLedgerType;
std::vector<txnMetaLedgerType>
getAccountTxsB(const RippleAddress& account, uint32 minL, uint32 maxL);
getAccountTxsB(const RippleAddress& account, uint32 minL, uint32 maxL, bool bAdmin);
std::vector<RippleAddress> getLedgerAffectedAccounts(uint32 ledgerSeq);
std::vector<SerializedTransaction> getLedgerTransactions(uint32 ledgerSeq);

View File

@@ -9,7 +9,6 @@
#include "Pathfinder.h"
#include "Log.h"
#include "NetworkOPs.h"
#include "RPCHandler.h"
#include "RPCSub.h"
#include "Application.h"
@@ -1706,7 +1705,8 @@ Json::Value RPCHandler::doAccountTransactions(Json::Value jvRequest, int& cost)
if (jvRequest.isMember("binary") && jvRequest["binary"].asBool())
{
std::vector<NetworkOPs::txnMetaLedgerType> txns =
mNetOps->getAccountTxsB(raAccount, minLedger, maxLedger);
mNetOps->getAccountTxsB(raAccount, minLedger, maxLedger, mRole == ADMIN);
for (std::vector<NetworkOPs::txnMetaLedgerType>::const_iterator it = txns.begin(), end = txns.end();
it != end; ++it)
{
@@ -1723,7 +1723,7 @@ Json::Value RPCHandler::doAccountTransactions(Json::Value jvRequest, int& cost)
}
else
{
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > txns = mNetOps->getAccountTxs(raAccount, minLedger, maxLedger);
std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> > txns = mNetOps->getAccountTxs(raAccount, minLedger, maxLedger, mRole == ADMIN);
for (std::vector< std::pair<Transaction::pointer, TransactionMetaSet::pointer> >::iterator it = txns.begin(), end = txns.end(); it != end; ++it)
{
Json::Value obj(Json::objectValue);

View File

@@ -8,6 +8,7 @@
#include "RippleAddress.h"
#include "SerializedTypes.h"
#include "Ledger.h"
#include "NetworkOPs.h"
#define LEDGER_CURRENT -1
#define LEDGER_CLOSED -2

View File

@@ -188,8 +188,17 @@ int main(int argc, char* argv[])
}
}
if (iResult)
{
nothing();
}
else if (vm.count("help"))
{
iResult = 1;
}
if (HaveSustain() &&
!vm.count("parameters") && !vm.count("fg") && !vm.count("standalone") && !vm.count("unittest"))
!iResult && !vm.count("parameters") && !vm.count("fg") && !vm.count("standalone") && !vm.count("unittest"))
{
std::string logMe = DoSustain();
if (!logMe.empty())
@@ -251,10 +260,6 @@ int main(int argc, char* argv[])
{
nothing();
}
else if (vm.count("help"))
{
iResult = 1;
}
else if (!vm.count("parameters"))
{
// No arguments. Run server.

View File

@@ -4,6 +4,10 @@
#include <sys/prctl.h>
#include <sys/wait.h>
#endif
#ifdef __FreeBSD__
#include <sys/types.h>
#include <sys/wait.h>
#endif
#include <fstream>
@@ -336,8 +340,8 @@ uint32_t htobe32(uint32_t value)
}
uint32_t be32toh(uint32_t value)
{
return( _byteswap_ulong(value));
{
return( _byteswap_ulong(value));
}
#endif
@@ -443,8 +447,8 @@ std::string DoSustain()
#else
bool HaveSustain() { return false; }
std::string DoSustain() { return std::string; }
std::string StopSustain() { return std::string; }
std::string DoSustain() { return std::string(); }
std::string StopSustain() { return std::string(); }
#endif