mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-02 16:26:48 +00:00
Logging cleanups.
This commit is contained in:
@@ -277,7 +277,7 @@ bool STAmount::setValue(const std::string& sAmount)
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "Bad integer amount: " << sAmount;
|
cLog(lsINFO) << "Bad integer amount: " << sAmount;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -304,7 +304,7 @@ bool STAmount::setValue(const std::string& sAmount)
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "Bad e amount: " << sAmount;
|
cLog(lsINFO) << "Bad e amount: " << sAmount;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -346,7 +346,7 @@ bool STAmount::setValue(const std::string& sAmount)
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "Bad float amount: " << sAmount;
|
cLog(lsINFO) << "Bad float amount: " << sAmount;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -391,7 +391,7 @@ bool STAmount::setFullValue(const std::string& sAmount, const std::string& sCurr
|
|||||||
//
|
//
|
||||||
if (!currencyFromString(mCurrency, sCurrency))
|
if (!currencyFromString(mCurrency, sCurrency))
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "Currency malformed: " << sCurrency;
|
cLog(lsINFO) << "Currency malformed: " << sCurrency;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -406,7 +406,7 @@ bool STAmount::setFullValue(const std::string& sAmount, const std::string& sCurr
|
|||||||
// Issuer must be "" or a valid account string.
|
// Issuer must be "" or a valid account string.
|
||||||
if (!naIssuerID.setAccountID(sIssuer))
|
if (!naIssuerID.setAccountID(sIssuer))
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "Issuer malformed: " << sIssuer;
|
cLog(lsINFO) << "Issuer malformed: " << sIssuer;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -416,7 +416,7 @@ bool STAmount::setFullValue(const std::string& sAmount, const std::string& sCurr
|
|||||||
// Stamps not must have an issuer.
|
// Stamps not must have an issuer.
|
||||||
if (mIsNative && !mIssuer.isZero())
|
if (mIsNative && !mIssuer.isZero())
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "Issuer specified for XRP: " << sIssuer;
|
cLog(lsINFO) << "Issuer specified for XRP: " << sIssuer;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1050,7 +1050,7 @@ bool STAmount::applyOffer(
|
|||||||
saTakerPaid = saOfferGets; // Taker paid what offer could get.
|
saTakerPaid = saOfferGets; // Taker paid what offer could get.
|
||||||
saTakerGot = saOfferPays; // Taker got what offer could pay.
|
saTakerGot = saOfferPays; // Taker got what offer could pay.
|
||||||
|
|
||||||
Log(lsINFO) << "applyOffer: took all outright";
|
cLog(lsINFO) << "applyOffer: took all outright";
|
||||||
}
|
}
|
||||||
else if (saTakerFunds >= saOfferGetsAvailable)
|
else if (saTakerFunds >= saOfferGetsAvailable)
|
||||||
{
|
{
|
||||||
@@ -1058,7 +1058,7 @@ bool STAmount::applyOffer(
|
|||||||
saTakerPaid = saOfferGetsAvailable; // Taker paid what offer could get.
|
saTakerPaid = saOfferGetsAvailable; // Taker paid what offer could get.
|
||||||
saTakerGot = saOfferPaysAvailable; // Taker got what offer could pay.
|
saTakerGot = saOfferPaysAvailable; // Taker got what offer could pay.
|
||||||
|
|
||||||
Log(lsINFO) << "applyOffer: took all available";
|
cLog(lsINFO) << "applyOffer: took all available";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1066,8 +1066,8 @@ bool STAmount::applyOffer(
|
|||||||
saTakerPaid = saTakerFunds; // Taker paid all he had.
|
saTakerPaid = saTakerFunds; // Taker paid all he had.
|
||||||
saTakerGot = divide(multiply(saTakerFunds, saOfferPaysAvailable, CURRENCY_ONE, ACCOUNT_ONE), saOfferGetsAvailable, saOfferPays.getCurrency(), saOfferPays.getIssuer());
|
saTakerGot = divide(multiply(saTakerFunds, saOfferPaysAvailable, CURRENCY_ONE, ACCOUNT_ONE), saOfferGetsAvailable, saOfferPays.getCurrency(), saOfferPays.getIssuer());
|
||||||
|
|
||||||
Log(lsINFO) << "applyOffer: saTakerGot=" << saTakerGot.getFullText();
|
cLog(lsINFO) << "applyOffer: saTakerGot=" << saTakerGot.getFullText();
|
||||||
Log(lsINFO) << "applyOffer: saOfferPaysAvailable=" << saOfferPaysAvailable.getFullText();
|
cLog(lsINFO) << "applyOffer: saOfferPaysAvailable=" << saOfferPaysAvailable.getFullText();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uTakerPaysRate == QUALITY_ONE)
|
if (uTakerPaysRate == QUALITY_ONE)
|
||||||
@@ -1394,7 +1394,7 @@ BOOST_AUTO_TEST_CASE( CustomCurrency_test )
|
|||||||
BOOST_FAIL("STAmount multiply fail");
|
BOOST_FAIL("STAmount multiply fail");
|
||||||
if (STAmount::divide(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount(3), CURRENCY_ONE, ACCOUNT_ONE).getText() != "20")
|
if (STAmount::divide(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 60), STAmount(3), CURRENCY_ONE, ACCOUNT_ONE).getText() != "20")
|
||||||
{
|
{
|
||||||
Log(lsFATAL) << "60/3 = " <<
|
cLog(lsFATAL) << "60/3 = " <<
|
||||||
STAmount::divide(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 60),
|
STAmount::divide(STAmount(CURRENCY_ONE, ACCOUNT_ONE, 60),
|
||||||
STAmount(3), CURRENCY_ONE, ACCOUNT_ONE).getText();
|
STAmount(3), CURRENCY_ONE, ACCOUNT_ONE).getText();
|
||||||
BOOST_FAIL("STAmount divide fail");
|
BOOST_FAIL("STAmount divide fail");
|
||||||
@@ -1449,7 +1449,7 @@ static void mulTest(int a, int b)
|
|||||||
STAmount prod2(CURRENCY_ONE, ACCOUNT_ONE, static_cast<uint64>(a) * static_cast<uint64>(b));
|
STAmount prod2(CURRENCY_ONE, ACCOUNT_ONE, static_cast<uint64>(a) * static_cast<uint64>(b));
|
||||||
if (prod1 != prod2)
|
if (prod1 != prod2)
|
||||||
{
|
{
|
||||||
Log(lsWARNING) << "nn(" << aa.getFullText() << " * " << bb.getFullText() << ") = " << prod1.getFullText()
|
cLog(lsWARNING) << "nn(" << aa.getFullText() << " * " << bb.getFullText() << ") = " << prod1.getFullText()
|
||||||
<< " not " << prod2.getFullText();
|
<< " not " << prod2.getFullText();
|
||||||
BOOST_WARN("Multiplication result is not exact");
|
BOOST_WARN("Multiplication result is not exact");
|
||||||
}
|
}
|
||||||
@@ -1457,7 +1457,7 @@ static void mulTest(int a, int b)
|
|||||||
prod1 = STAmount::multiply(aa, bb, CURRENCY_ONE, ACCOUNT_ONE);
|
prod1 = STAmount::multiply(aa, bb, CURRENCY_ONE, ACCOUNT_ONE);
|
||||||
if (prod1 != prod2)
|
if (prod1 != prod2)
|
||||||
{
|
{
|
||||||
Log(lsWARNING) << "n(" << aa.getFullText() << " * " << bb.getFullText() << ") = " << prod1.getFullText()
|
cLog(lsWARNING) << "n(" << aa.getFullText() << " * " << bb.getFullText() << ") = " << prod1.getFullText()
|
||||||
<< " not " << prod2.getFullText();
|
<< " not " << prod2.getFullText();
|
||||||
BOOST_WARN("Multiplication result is not exact");
|
BOOST_WARN("Multiplication result is not exact");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1232,10 +1232,10 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
|
|||||||
|
|
||||||
if (sLog(lsTRACE))
|
if (sLog(lsTRACE))
|
||||||
{
|
{
|
||||||
Log(lsTRACE) << "newLCL";
|
cLog(lsTRACE) << "newLCL";
|
||||||
Json::Value p;
|
Json::Value p;
|
||||||
newLCL->addJson(p, LEDGER_JSON_DUMP_TXRP | LEDGER_JSON_DUMP_STATE);
|
newLCL->addJson(p, LEDGER_JSON_DUMP_TXRP | LEDGER_JSON_DUMP_STATE);
|
||||||
Log(lsTRACE) << p;
|
cLog(lsTRACE) << p;
|
||||||
}
|
}
|
||||||
|
|
||||||
statusChange(ripple::neACCEPTED_LEDGER, *newLCL);
|
statusChange(ripple::neACCEPTED_LEDGER, *newLCL);
|
||||||
|
|||||||
@@ -1006,7 +1006,7 @@ Json::Value RPCHandler::doSubmit(Json::Value jvRequest)
|
|||||||
{
|
{
|
||||||
naMasterAccountPublic.setAccountPublic(naMasterGenerator, iIndex);
|
naMasterAccountPublic.setAccountPublic(naMasterGenerator, iIndex);
|
||||||
|
|
||||||
Log(lsWARNING) << "authorize: " << iIndex << " : " << naMasterAccountPublic.humanAccountID() << " : " << raSrcAddressID.humanAccountID();
|
cLog(lsWARNING) << "authorize: " << iIndex << " : " << naMasterAccountPublic.humanAccountID() << " : " << raSrcAddressID.humanAccountID();
|
||||||
|
|
||||||
bFound = raSrcAddressID.getAccountID() == naMasterAccountPublic.getAccountID();
|
bFound = raSrcAddressID.getAccountID() == naMasterAccountPublic.getAccountID();
|
||||||
if (!bFound)
|
if (!bFound)
|
||||||
|
|||||||
@@ -707,7 +707,7 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeExternal(const SHAMapNode& id, const ui
|
|||||||
HashedObject::pointer obj(theApp->getHashedObjectStore().retrieve(hash));
|
HashedObject::pointer obj(theApp->getHashedObjectStore().retrieve(hash));
|
||||||
if (!obj)
|
if (!obj)
|
||||||
{
|
{
|
||||||
// Log(lsTRACE) << "fetchNodeExternal: missing " << hash;
|
// cLog(lsTRACE) << "fetchNodeExternal: missing " << hash;
|
||||||
throw SHAMapMissingNode(mType, id, hash);
|
throw SHAMapMissingNode(mType, id, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -716,13 +716,13 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeExternal(const SHAMapNode& id, const ui
|
|||||||
SHAMapTreeNode::pointer ret = boost::make_shared<SHAMapTreeNode>(id, obj->getData(), mSeq - 1, snfPREFIX);
|
SHAMapTreeNode::pointer ret = boost::make_shared<SHAMapTreeNode>(id, obj->getData(), mSeq - 1, snfPREFIX);
|
||||||
if (id != *ret)
|
if (id != *ret)
|
||||||
{
|
{
|
||||||
Log(lsFATAL) << "id:" << id << ", got:" << *ret;
|
cLog(lsFATAL) << "id:" << id << ", got:" << *ret;
|
||||||
assert(false);
|
assert(false);
|
||||||
return SHAMapTreeNode::pointer();
|
return SHAMapTreeNode::pointer();
|
||||||
}
|
}
|
||||||
if (ret->getNodeHash() != hash)
|
if (ret->getNodeHash() != hash)
|
||||||
{
|
{
|
||||||
Log(lsFATAL) << "Hashes don't match";
|
cLog(lsFATAL) << "Hashes don't match";
|
||||||
assert(false);
|
assert(false);
|
||||||
return SHAMapTreeNode::pointer();
|
return SHAMapTreeNode::pointer();
|
||||||
}
|
}
|
||||||
@@ -745,11 +745,11 @@ void SHAMap::fetchRoot(const uint256& hash)
|
|||||||
if (sLog(lsTRACE))
|
if (sLog(lsTRACE))
|
||||||
{
|
{
|
||||||
if (mType == smtTRANSACTION)
|
if (mType == smtTRANSACTION)
|
||||||
Log(lsTRACE) << "Fetch root TXN node " << hash;
|
cLog(lsTRACE) << "Fetch root TXN node " << hash;
|
||||||
else if (mType == smtSTATE)
|
else if (mType == smtSTATE)
|
||||||
Log(lsTRACE) << "Fetch root STATE node " << hash;
|
cLog(lsTRACE) << "Fetch root STATE node " << hash;
|
||||||
else
|
else
|
||||||
Log(lsTRACE) << "Fetch root SHAMap node " << hash;
|
cLog(lsTRACE) << "Fetch root SHAMap node " << hash;
|
||||||
}
|
}
|
||||||
root = fetchNodeExternal(SHAMapNode(), hash);
|
root = fetchNodeExternal(SHAMapNode(), hash);
|
||||||
assert(root->getNodeHash() == hash);
|
assert(root->getNodeHash() == hash);
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "HashPrefixes.h"
|
#include "HashPrefixes.h"
|
||||||
|
|
||||||
|
SETUP_LOG();
|
||||||
|
|
||||||
std::string SHAMapNode::getString() const
|
std::string SHAMapNode::getString() const
|
||||||
{
|
{
|
||||||
static boost::format NodeID("NodeID(%s,%s)");
|
static boost::format NodeID("NodeID(%s,%s)");
|
||||||
@@ -170,7 +172,7 @@ int SHAMapNode::selectBranch(const uint256& hash) const
|
|||||||
|
|
||||||
void SHAMapNode::dump() const
|
void SHAMapNode::dump() const
|
||||||
{
|
{
|
||||||
Log(lsDEBUG) << getString();
|
cLog(lsDEBUG) << getString();
|
||||||
}
|
}
|
||||||
|
|
||||||
SHAMapTreeNode::SHAMapTreeNode(uint32 seq, const SHAMapNode& nodeID) : SHAMapNode(nodeID), mHash(0),
|
SHAMapTreeNode::SHAMapTreeNode(uint32 seq, const SHAMapNode& nodeID) : SHAMapNode(nodeID), mHash(0),
|
||||||
@@ -265,7 +267,7 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned
|
|||||||
{
|
{
|
||||||
if (rawNode.size() < 4)
|
if (rawNode.size() < 4)
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "size < 4";
|
cLog(lsINFO) << "size < 4";
|
||||||
throw std::runtime_error("invalid P node");
|
throw std::runtime_error("invalid P node");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,7 +289,7 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned
|
|||||||
s.chop(32);
|
s.chop(32);
|
||||||
if (u.isZero())
|
if (u.isZero())
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "invalid PLN node";
|
cLog(lsINFO) << "invalid PLN node";
|
||||||
throw std::runtime_error("invalid PLN node");
|
throw std::runtime_error("invalid PLN node");
|
||||||
}
|
}
|
||||||
mItem = boost::make_shared<SHAMapItem>(u, s.peekData());
|
mItem = boost::make_shared<SHAMapItem>(u, s.peekData());
|
||||||
@@ -313,7 +315,7 @@ SHAMapTreeNode::SHAMapTreeNode(const SHAMapNode& id, const std::vector<unsigned
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "Unknown node prefix " << std::hex << prefix << std::dec;
|
cLog(lsINFO) << "Unknown node prefix " << std::hex << prefix << std::dec;
|
||||||
throw std::runtime_error("invalid node prefix");
|
throw std::runtime_error("invalid node prefix");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -510,7 +512,7 @@ void SHAMapTreeNode::makeInner()
|
|||||||
|
|
||||||
void SHAMapTreeNode::dump()
|
void SHAMapTreeNode::dump()
|
||||||
{
|
{
|
||||||
Log(lsDEBUG) << "SHAMapTreeNode(" << getNodeID() << ")";
|
cLog(lsDEBUG) << "SHAMapTreeNode(" << getNodeID() << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SHAMapTreeNode::getString() const
|
std::string SHAMapTreeNode::getString() const
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
|
SETUP_LOG();
|
||||||
|
|
||||||
// #define SNTP_DEBUG
|
// #define SNTP_DEBUG
|
||||||
|
|
||||||
static uint8_t SNTPQueryData[48] =
|
static uint8_t SNTPQueryData[48] =
|
||||||
@@ -73,7 +75,7 @@ void SNTPClient::resolveComplete(const boost::system::error_code& error, boost::
|
|||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
if ((query.mLocalTimeSent == now) || ((query.mLocalTimeSent + 1) == now))
|
if ((query.mLocalTimeSent == now) || ((query.mLocalTimeSent + 1) == now))
|
||||||
{ // This can happen if the same IP address is reached through multiple names
|
{ // This can happen if the same IP address is reached through multiple names
|
||||||
Log(lsTRACE) << "SNTP: Redundant query suppressed";
|
cLog(lsTRACE) << "SNTP: Redundant query suppressed";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
query.mReceivedReply = false;
|
query.mReceivedReply = false;
|
||||||
@@ -94,23 +96,23 @@ void SNTPClient::receivePacket(const boost::system::error_code& error, std::size
|
|||||||
{
|
{
|
||||||
boost::mutex::scoped_lock sl(mLock);
|
boost::mutex::scoped_lock sl(mLock);
|
||||||
#ifdef SNTP_DEBUG
|
#ifdef SNTP_DEBUG
|
||||||
Log(lsTRACE) << "SNTP: Packet from " << mReceiveEndpoint;
|
cLog(lsTRACE) << "SNTP: Packet from " << mReceiveEndpoint;
|
||||||
#endif
|
#endif
|
||||||
std::map<boost::asio::ip::udp::endpoint, SNTPQuery>::iterator query = mQueries.find(mReceiveEndpoint);
|
std::map<boost::asio::ip::udp::endpoint, SNTPQuery>::iterator query = mQueries.find(mReceiveEndpoint);
|
||||||
if (query == mQueries.end())
|
if (query == mQueries.end())
|
||||||
Log(lsDEBUG) << "SNTP: Reply from " << mReceiveEndpoint << " found without matching query";
|
cLog(lsDEBUG) << "SNTP: Reply from " << mReceiveEndpoint << " found without matching query";
|
||||||
else if (query->second.mReceivedReply)
|
else if (query->second.mReceivedReply)
|
||||||
Log(lsDEBUG) << "SNTP: Duplicate response from " << mReceiveEndpoint;
|
cLog(lsDEBUG) << "SNTP: Duplicate response from " << mReceiveEndpoint;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
query->second.mReceivedReply = true;
|
query->second.mReceivedReply = true;
|
||||||
if (time(NULL) > (query->second.mLocalTimeSent + 1))
|
if (time(NULL) > (query->second.mLocalTimeSent + 1))
|
||||||
Log(lsWARNING) << "SNTP: Late response from " << mReceiveEndpoint;
|
cLog(lsWARNING) << "SNTP: Late response from " << mReceiveEndpoint;
|
||||||
else if (bytes_xferd < 48)
|
else if (bytes_xferd < 48)
|
||||||
Log(lsWARNING) << "SNTP: Short reply from " << mReceiveEndpoint
|
cLog(lsWARNING) << "SNTP: Short reply from " << mReceiveEndpoint
|
||||||
<< " (" << bytes_xferd << ") " << mReceiveBuffer.size();
|
<< " (" << bytes_xferd << ") " << mReceiveBuffer.size();
|
||||||
else if (reinterpret_cast<uint32*>(&mReceiveBuffer[0])[NTP_OFF_ORGTS_FRAC] != query->second.mQueryNonce)
|
else if (reinterpret_cast<uint32*>(&mReceiveBuffer[0])[NTP_OFF_ORGTS_FRAC] != query->second.mQueryNonce)
|
||||||
Log(lsWARNING) << "SNTP: Reply from " << mReceiveEndpoint << "had wrong nonce";
|
cLog(lsWARNING) << "SNTP: Reply from " << mReceiveEndpoint << "had wrong nonce";
|
||||||
else
|
else
|
||||||
processReply();
|
processReply();
|
||||||
}
|
}
|
||||||
@@ -123,8 +125,7 @@ void SNTPClient::receivePacket(const boost::system::error_code& error, std::size
|
|||||||
|
|
||||||
void SNTPClient::sendComplete(const boost::system::error_code& error, std::size_t)
|
void SNTPClient::sendComplete(const boost::system::error_code& error, std::size_t)
|
||||||
{
|
{
|
||||||
if (error)
|
tLog(error, lsWARNING) << "SNTP: Send error";
|
||||||
Log(lsWARNING) << "SNTP: Send error";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SNTPClient::processReply()
|
void SNTPClient::processReply()
|
||||||
@@ -138,12 +139,12 @@ void SNTPClient::processReply()
|
|||||||
|
|
||||||
if ((info >> 30) == 3)
|
if ((info >> 30) == 3)
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "SNTP: Alarm condition " << mReceiveEndpoint;
|
cLog(lsINFO) << "SNTP: Alarm condition " << mReceiveEndpoint;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((stratum == 0) || (stratum > 14))
|
if ((stratum == 0) || (stratum > 14))
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "SNTP: Unreasonable stratum (" << stratum << ") from " << mReceiveEndpoint;
|
cLog(lsINFO) << "SNTP: Unreasonable stratum (" << stratum << ") from " << mReceiveEndpoint;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,10 +172,7 @@ void SNTPClient::processReply()
|
|||||||
if ((mOffset == -1) || (mOffset == 1)) // small corrections likely do more harm than good
|
if ((mOffset == -1) || (mOffset == 1)) // small corrections likely do more harm than good
|
||||||
mOffset = 0;
|
mOffset = 0;
|
||||||
|
|
||||||
#ifndef SNTP_DEBUG
|
tLog(timev || mOffset, lsTRACE) << "SNTP: Offset is " << timev << ", new system offset is " << mOffset;
|
||||||
if (timev || mOffset)
|
|
||||||
#endif
|
|
||||||
Log(lsTRACE) << "SNTP: Offset is " << timev << ", new system offset is " << mOffset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SNTPClient::timerEntry(const boost::system::error_code& error)
|
void SNTPClient::timerEntry(const boost::system::error_code& error)
|
||||||
@@ -198,7 +196,7 @@ void SNTPClient::init(const std::vector<std::string>& servers)
|
|||||||
std::vector<std::string>::const_iterator it = servers.begin();
|
std::vector<std::string>::const_iterator it = servers.begin();
|
||||||
if (it == servers.end())
|
if (it == servers.end())
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "SNTP: no server specified";
|
cLog(lsINFO) << "SNTP: no server specified";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(const std::string& it, servers)
|
BOOST_FOREACH(const std::string& it, servers)
|
||||||
@@ -231,13 +229,13 @@ bool SNTPClient::doQuery()
|
|||||||
best = it;
|
best = it;
|
||||||
if (best == mServers.end())
|
if (best == mServers.end())
|
||||||
{
|
{
|
||||||
Log(lsINFO) << "SNTP: No server to query";
|
cLog(lsINFO) << "SNTP: No server to query";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
if ((best->second != (time_t) -1) && ((best->second + NTP_MIN_QUERY) >= now))
|
if ((best->second != (time_t) -1) && ((best->second + NTP_MIN_QUERY) >= now))
|
||||||
{
|
{
|
||||||
Log(lsTRACE) << "SNTP: All servers recently queried";
|
cLog(lsTRACE) << "SNTP: All servers recently queried";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
best->second = now;
|
best->second = now;
|
||||||
@@ -247,7 +245,7 @@ bool SNTPClient::doQuery()
|
|||||||
boost::bind(&SNTPClient::resolveComplete, this,
|
boost::bind(&SNTPClient::resolveComplete, this,
|
||||||
boost::asio::placeholders::error, boost::asio::placeholders::iterator));
|
boost::asio::placeholders::error, boost::asio::placeholders::iterator));
|
||||||
#ifdef SNTP_DEBUG
|
#ifdef SNTP_DEBUG
|
||||||
Log(lsTRACE) << "SNTP: Resolve pending for " << best->first;
|
cLog(lsTRACE) << "SNTP: Resolve pending for " << best->first;
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
|
||||||
DECLARE_INSTANCE(SerializedLedgerEntry)
|
DECLARE_INSTANCE(SerializedLedgerEntry)
|
||||||
|
SETUP_LOG();
|
||||||
|
|
||||||
SerializedLedgerEntry::SerializedLedgerEntry(SerializerIterator& sit, const uint256& index)
|
SerializedLedgerEntry::SerializedLedgerEntry(SerializerIterator& sit, const uint256& index)
|
||||||
: STObject(sfLedgerEntry), mIndex(index)
|
: STObject(sfLedgerEntry), mIndex(index)
|
||||||
@@ -33,8 +34,8 @@ SerializedLedgerEntry::SerializedLedgerEntry(const Serializer& s, const uint256&
|
|||||||
mType = mFormat->t_type;
|
mType = mFormat->t_type;
|
||||||
if (!setType(mFormat->elements))
|
if (!setType(mFormat->elements))
|
||||||
{
|
{
|
||||||
Log(lsWARNING) << "Ledger entry not valid for type " << mFormat->t_name;
|
cLog(lsWARNING) << "Ledger entry not valid for type " << mFormat->t_name;
|
||||||
Log(lsWARNING) << getJson(0);
|
cLog(lsWARNING) << getJson(0);
|
||||||
throw std::runtime_error("ledger entry not valid for type");
|
throw std::runtime_error("ledger entry not valid for type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,7 +100,7 @@ uint32 SerializedLedgerEntry::getThreadedLedger()
|
|||||||
bool SerializedLedgerEntry::thread(const uint256& txID, uint32 ledgerSeq, uint256& prevTxID, uint32& prevLedgerID)
|
bool SerializedLedgerEntry::thread(const uint256& txID, uint32 ledgerSeq, uint256& prevTxID, uint32& prevLedgerID)
|
||||||
{
|
{
|
||||||
uint256 oldPrevTxID = getFieldH256(sfPreviousTxnID);
|
uint256 oldPrevTxID = getFieldH256(sfPreviousTxnID);
|
||||||
Log(lsTRACE) << "Thread Tx:" << txID << " prev:" << oldPrevTxID;
|
cLog(lsTRACE) << "Thread Tx:" << txID << " prev:" << oldPrevTxID;
|
||||||
if (oldPrevTxID == txID)
|
if (oldPrevTxID == txID)
|
||||||
{ // this transaction is already threaded
|
{ // this transaction is already threaded
|
||||||
assert(getFieldU32(sfPreviousTxnLgrSeq) == ledgerSeq);
|
assert(getFieldU32(sfPreviousTxnLgrSeq) == ledgerSeq);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ void WSDoor::startListening()
|
|||||||
}
|
}
|
||||||
catch (websocketpp::exception& e)
|
catch (websocketpp::exception& e)
|
||||||
{
|
{
|
||||||
Log(lsWARNING) << "websocketpp exception: " << e.what();
|
cLog(lsWARNING) << "websocketpp exception: " << e.what();
|
||||||
while (1) // temporary workaround for websocketpp throwing exceptions on access/close races
|
while (1) // temporary workaround for websocketpp throwing exceptions on access/close races
|
||||||
{ // https://github.com/zaphoyd/websocketpp/issues/98
|
{ // https://github.com/zaphoyd/websocketpp/issues/98
|
||||||
try
|
try
|
||||||
@@ -88,7 +88,7 @@ void WSDoor::startListening()
|
|||||||
}
|
}
|
||||||
catch (websocketpp::exception& e)
|
catch (websocketpp::exception& e)
|
||||||
{
|
{
|
||||||
Log(lsWARNING) << "websocketpp exception: " << e.what();
|
cLog(lsWARNING) << "websocketpp exception: " << e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ void WSDoor::startListening()
|
|||||||
}
|
}
|
||||||
catch (websocketpp::exception& e)
|
catch (websocketpp::exception& e)
|
||||||
{
|
{
|
||||||
Log(lsWARNING) << "websocketpp exception: " << e.what();
|
cLog(lsWARNING) << "websocketpp exception: " << e.what();
|
||||||
while (1) // temporary workaround for websocketpp throwing exceptions on access/close races
|
while (1) // temporary workaround for websocketpp throwing exceptions on access/close races
|
||||||
{ // https://github.com/zaphoyd/websocketpp/issues/98
|
{ // https://github.com/zaphoyd/websocketpp/issues/98
|
||||||
try
|
try
|
||||||
@@ -124,7 +124,7 @@ void WSDoor::startListening()
|
|||||||
}
|
}
|
||||||
catch (websocketpp::exception& e)
|
catch (websocketpp::exception& e)
|
||||||
{
|
{
|
||||||
Log(lsWARNING) << "websocketpp exception: " << e.what();
|
cLog(lsWARNING) << "websocketpp exception: " << e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user