Change the use of integrals to chrono types as appropriate

This commit is contained in:
Howard Hinnant
2015-11-16 17:45:31 -05:00
committed by Nik Bougalis
parent bacf2605a4
commit e86ff5daa1
60 changed files with 522 additions and 490 deletions

View File

@@ -40,7 +40,7 @@ Json::Value doPeers (RPC::Context& context)
jvResult[jss::peers] = context.app.overlay ().json ();
auto const now = context.app.timeKeeper().now().time_since_epoch().count();
auto const now = context.app.timeKeeper().now();
auto const self = context.app.getLocalCredentials().getNodePublic();
Json::Value& cluster = (jvResult[jss::cluster] = Json::objectValue);
@@ -60,10 +60,10 @@ Json::Value doPeers (RPC::Context& context)
if ((node.getLoadFee() != ref) && (node.getLoadFee() != 0))
json[jss::fee] = static_cast<double>(node.getLoadFee()) / ref;
if (node.getReportTime())
if (node.getReportTime() != NetClock::time_point{})
json[jss::age] = (node.getReportTime() >= now)
? 0
: (now - node.getReportTime());
: (now - node.getReportTime()).count();
});
}

View File

@@ -240,7 +240,7 @@ checkTxJsonFields (
Json::Value const& tx_json,
Role const role,
bool const verify,
int validatedLedgerAge,
std::chrono::seconds validatedLedgerAge,
Config const& config,
LoadFeeTrack const& feeTrack)
{
@@ -333,7 +333,7 @@ transactionPreProcessImpl (
Json::Value& params,
Role role,
SigningForParams& signingArgs,
int validatedLedgerAge,
std::chrono::seconds validatedLedgerAge,
Application& app,
std::shared_ptr<ReadView const> ledger)
{
@@ -673,7 +673,7 @@ Json::Value transactionSign (
Json::Value jvRequest,
NetworkOPs::FailHard failType,
Role role,
int validatedLedgerAge,
std::chrono::seconds validatedLedgerAge,
Application& app,
std::shared_ptr<ReadView const> ledger,
ApplyFlags flags)
@@ -708,7 +708,7 @@ Json::Value transactionSubmit (
Json::Value jvRequest,
NetworkOPs::FailHard failType,
Role role,
int validatedLedgerAge,
std::chrono::seconds validatedLedgerAge,
Application& app,
std::shared_ptr<ReadView const> ledger,
ProcessTransactionFn const& processTransaction,
@@ -834,7 +834,7 @@ Json::Value transactionSignFor (
Json::Value jvRequest,
NetworkOPs::FailHard failType,
Role role,
int validatedLedgerAge,
std::chrono::seconds validatedLedgerAge,
Application& app,
std::shared_ptr<ReadView const> ledger,
ApplyFlags flags)
@@ -944,7 +944,7 @@ Json::Value transactionSubmitMultiSigned (
Json::Value jvRequest,
NetworkOPs::FailHard failType,
Role role,
int validatedLedgerAge,
std::chrono::seconds validatedLedgerAge,
Application& app,
std::shared_ptr<ReadView const> ledger,
ProcessTransactionFn const& processTransaction,

View File

@@ -81,7 +81,7 @@ Json::Value transactionSign (
Json::Value params, // Passed by value so it can be modified locally.
NetworkOPs::FailHard failType,
Role role,
int validatedLedgerAge,
std::chrono::seconds validatedLedgerAge,
Application& app,
std::shared_ptr<ReadView const> ledger,
ApplyFlags flags = tapNONE);
@@ -91,7 +91,7 @@ Json::Value transactionSubmit (
Json::Value params, // Passed by value so it can be modified locally.
NetworkOPs::FailHard failType,
Role role,
int validatedLedgerAge,
std::chrono::seconds validatedLedgerAge,
Application& app,
std::shared_ptr<ReadView const> ledger,
ProcessTransactionFn const& processTransaction,
@@ -102,7 +102,7 @@ Json::Value transactionSignFor (
Json::Value params, // Passed by value so it can be modified locally.
NetworkOPs::FailHard failType,
Role role,
int validatedLedgerAge,
std::chrono::seconds validatedLedgerAge,
Application& app,
std::shared_ptr<ReadView const> ledger,
ApplyFlags flags = tapNONE);
@@ -112,7 +112,7 @@ Json::Value transactionSubmitMultiSigned (
Json::Value params, // Passed by value so it can be modified locally.
NetworkOPs::FailHard failType,
Role role,
int validatedLedgerAge,
std::chrono::seconds validatedLedgerAge,
Application& app,
std::shared_ptr<ReadView const> ledger,
ProcessTransactionFn const& processTransaction,

View File

@@ -51,7 +51,8 @@ static int const defaultAutoFillFeeMultiplier = 10;
static int const maxPathfindsInProgress = 2;
static int const maxPathfindJobCount = 50;
static int const maxJobQueueClients = 500;
static int const maxValidatedLedgerAge = 120;
using namespace std::chrono_literals;
auto constexpr maxValidatedLedgerAge = 2min;
static int const maxRequestSize = 1000000;
/** Maximum number of pages in one response from a binary LedgerData request. */

View File

@@ -69,9 +69,10 @@ addPaymentDeliveredAmount (
// If the ledger closed long after the DeliveredAmount code was deployed
// then its absence indicates that the amount delivered is listed in the
// Amount field. DeliveredAmount went live January 24, 2014.
using namespace std::chrono_literals;
auto ct =
context.ledgerMaster.getCloseTimeBySeq (transaction->getLedger ());
if (ct && (*ct > 446000000))
if (ct && (*ct > NetClock::time_point{446000000s}))
{
// 446000000 is in Feb 2014, well after DeliveredAmount went live
meta[jss::delivered_amount] =

View File

@@ -1639,6 +1639,7 @@ public:
void testTransactionRPC ()
{
using namespace std::chrono_literals;
// Use jtx to set up a ledger so the tests will do the right thing.
test::jtx::Account const a {"a"}; // rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA
test::jtx::Account const g {"g"}; // rLPwWB1itaUGMV8kbMLLysjGkEpTM2Soy4
@@ -1666,7 +1667,7 @@ public:
Json::Value params,
NetworkOPs::FailHard failType,
Role role,
int validatedLedgerAge,
std::chrono::seconds validatedLedgerAge,
Application& app,
std::shared_ptr<ReadView const> ledger,
ApplyFlags flags);
@@ -1675,7 +1676,7 @@ public:
Json::Value params,
NetworkOPs::FailHard failType,
Role role,
int validatedLedgerAge,
std::chrono::seconds validatedLedgerAge,
Application& app,
std::shared_ptr<ReadView const> ledger,
ProcessTransactionFn const& processTransaction,
@@ -1717,7 +1718,7 @@ public:
req,
NetworkOPs::FailHard::yes,
testRole,
1,
1s,
env.app(),
ledger,
tapENABLE_TESTING);
@@ -1730,7 +1731,7 @@ public:
req,
NetworkOPs::FailHard::yes,
testRole,
1,
1s,
env.app(),
ledger,
processTxn,