mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-02 00:45:58 +00:00
Always use UTC to be timezone-neutral (RIPD-1659)
This commit is contained in:
committed by
Nik Bougalis
parent
de1d102535
commit
8b97466285
@@ -66,6 +66,7 @@ inline
|
||||
std::string
|
||||
to_string(NetClock::time_point tp)
|
||||
{
|
||||
// 2000-01-01 00:00:00 UTC is 946684800s from 1970-01-01 00:00:00 UTC
|
||||
using namespace std::chrono;
|
||||
return to_string(
|
||||
system_clock::time_point{tp.time_since_epoch() + 946684800s});
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
/** Returns the estimate of wall time, in network time.
|
||||
|
||||
The network time is wall time adjusted for the Ripple
|
||||
epoch, the beginning of January 1st, 2000. Each server
|
||||
epoch, the beginning of January 1st, 2000 UTC. Each server
|
||||
can compute a different value for network time. Other
|
||||
servers value for network time is not directly observable,
|
||||
but good guesses can be made by looking at validators'
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace ripple {
|
||||
NetClock::time_point const& fix1141Time ()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
// Fri July 1, 2016 10:00:00am PDT
|
||||
// Fri July 1, 2016 17:00:00 UTC
|
||||
static NetClock::time_point const soTime{520707600s};
|
||||
return soTime;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ bool fix1141 (NetClock::time_point const closeTime)
|
||||
NetClock::time_point const& fix1274Time ()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
// Fri Sep 30, 2016 10:00:00am PDT
|
||||
// Fri Sep 30, 2016 17:00:00 UTC
|
||||
static NetClock::time_point const soTime{528570000s};
|
||||
|
||||
return soTime;
|
||||
@@ -63,7 +63,7 @@ bool fix1274 (NetClock::time_point const closeTime)
|
||||
NetClock::time_point const& fix1298Time ()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
// Wed Dec 21, 2016 10:00:00am PST
|
||||
// Wed Dec 21, 2016 18:00:00 UTC
|
||||
static NetClock::time_point const soTime{535658400s};
|
||||
|
||||
return soTime;
|
||||
@@ -77,7 +77,7 @@ bool fix1298 (NetClock::time_point const closeTime)
|
||||
NetClock::time_point const& fix1443Time ()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
// Sat Mar 11, 2017 05:00:00pm PST
|
||||
// Sun Mar 12, 2017 01:00:00 UTC
|
||||
static NetClock::time_point const soTime{542595600s};
|
||||
|
||||
return soTime;
|
||||
@@ -91,7 +91,7 @@ bool fix1443 (NetClock::time_point const closeTime)
|
||||
NetClock::time_point const& fix1449Time ()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
// Thurs, Mar 30, 2017 01:00:00pm PDT
|
||||
// Thurs, Mar 30, 2017 20:00:00 UTC
|
||||
static NetClock::time_point const soTime{544219200s};
|
||||
|
||||
return soTime;
|
||||
|
||||
@@ -426,10 +426,10 @@ public:
|
||||
*stAmountCalcSwitchover2 = saved2_;
|
||||
}
|
||||
|
||||
// Mon Dec 28, 2015 10:00:00am PST
|
||||
// Mon Dec 28, 2015 18:00:00 UTC
|
||||
static NetClock::time_point const soTime;
|
||||
|
||||
// Mon Mar 28, 2015 10:00:00am PST
|
||||
// Sat Feb 27, 2016 05:00:00 UTC
|
||||
static NetClock::time_point const soTime2;
|
||||
|
||||
private:
|
||||
|
||||
@@ -39,9 +39,11 @@ LocalValue<bool> stAmountCalcSwitchover(true);
|
||||
LocalValue<bool> stAmountCalcSwitchover2(true);
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
// Mon Dec 28, 2015 18:00:00 UTC
|
||||
const NetClock::time_point STAmountSO::soTime{504640800s};
|
||||
|
||||
// Fri Feb 26, 2016 9:00:00pm PST
|
||||
// Sat Feb 27, 2016 05:00:00 UTC
|
||||
const NetClock::time_point STAmountSO::soTime2{509864400s};
|
||||
|
||||
static const std::uint64_t tenTo14 = 100000000000000ull;
|
||||
|
||||
@@ -394,6 +394,86 @@ parseAccountIds(Json::Value const& jvArray)
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
addPaymentDeliveredAmount(Json::Value& meta, RPC::Context& context,
|
||||
std::shared_ptr<Transaction> transaction, TxMeta::pointer transactionMeta)
|
||||
{
|
||||
// We only want to add a "delivered_amount" field if the transaction
|
||||
// succeeded - otherwise nothing could have been delivered.
|
||||
if (! transaction)
|
||||
return;
|
||||
|
||||
auto const serializedTx = transaction->getSTransaction ();
|
||||
if (! serializedTx)
|
||||
return;
|
||||
|
||||
{
|
||||
// Only include this field for Payment and CheckCash transactions.
|
||||
TxType const tt {serializedTx->getTxnType()};
|
||||
if ((tt != ttPAYMENT) && (tt != ttCHECK_CASH))
|
||||
return;
|
||||
|
||||
// Only include this field for CheckCash transactions if the fix
|
||||
// is enabled.
|
||||
if (tt == ttCHECK_CASH)
|
||||
{
|
||||
auto const view = context.app.openLedger().current();
|
||||
if (!view || !view->rules().enabled (fix1623))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (transactionMeta)
|
||||
{
|
||||
if (transactionMeta->getResultTER() != tesSUCCESS)
|
||||
return;
|
||||
|
||||
// If the transaction explicitly specifies a DeliveredAmount in the
|
||||
// metadata then we use it.
|
||||
if (transactionMeta->hasDeliveredAmount ())
|
||||
{
|
||||
meta[jss::delivered_amount] =
|
||||
transactionMeta->getDeliveredAmount ().getJson (1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (transaction->getResult() != tesSUCCESS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (serializedTx->isFieldPresent (sfAmount))
|
||||
{
|
||||
// Ledger 4594095 is the first ledger in which the DeliveredAmount field
|
||||
// was present when a partial payment was made and its absence indicates
|
||||
// that the amount delivered is listed in the Amount field.
|
||||
if (transaction->getLedger () >= 4594095)
|
||||
{
|
||||
meta[jss::delivered_amount] =
|
||||
serializedTx->getFieldAmount (sfAmount).getJson (1);
|
||||
return;
|
||||
}
|
||||
|
||||
// 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 const ct =
|
||||
context.ledgerMaster.getCloseTimeBySeq (transaction->getLedger ());
|
||||
if (ct && (*ct > NetClock::time_point{446000000s}))
|
||||
{
|
||||
// 446000000 is 2014-02-18 00:53:20 UTC, well after DeliveredAmount went live
|
||||
meta[jss::delivered_amount] =
|
||||
serializedTx->getFieldAmount (sfAmount).getJson (1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise we report "unavailable" which cannot be parsed into a
|
||||
// sensible amount.
|
||||
meta[jss::delivered_amount] = Json::Value ("unavailable");
|
||||
}
|
||||
|
||||
void
|
||||
injectSLE(Json::Value& jv, SLE const& sle)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user