void terminateHandler() { if (std::current_exception()) { std::string const name = threadName.get() ? *threadName.get() : "Unknown"; try { throw; } catch (const std::exception& e) { std::cerr << name << ": " << e.what () << '\n'; JLOG(debugLog().fatal()) << name << ": " << e.what () << '\n'; } catch (boost::coroutines::detail::forced_unwind const&) { std::cerr << name << ": forced_unwind\n"; JLOG(debugLog().fatal()) << name << ": forced_unwind\n"; } catch (...) { std::cerr << name << ": unknown exception\n"; JLOG (debugLog ().fatal ()) << name << ": unknown exception\n"; } } }
Status doCommand ( RPC::Context& context, Json::Value& result) { Handler const * handler = nullptr; if (auto error = fillHandler (context, handler)) { inject_error (error, result); return error; } if (auto method = handler->valueMethod_) { if (! context.headers.user.empty() || ! context.headers.forwardedFor.empty()) { JLOG(context.j.debug()) << "start command: " << handler->name_ << ", X-User: "******", X-Forwarded-For: " << context.headers.forwardedFor; auto ret = callMethod (context, method, handler->name_, result); JLOG(context.j.debug()) << "finish command: " << handler->name_ << ", X-User: "******", X-Forwarded-For: " << context.headers.forwardedFor; return ret; } else { return callMethod (context, method, handler->name_, result); } } return rpcUNKNOWN_COMMAND; }
// Checks the cache size and prunes if its over the limit. void Bootcache::prune () { if (size() <= Tuning::bootcacheSize) return; // Calculate the amount to remove auto count ((size() * Tuning::bootcachePrunePercent) / 100); decltype(count) pruned (0); // Work backwards because bimap doesn't handle // erasing using a reverse iterator very well. // for (auto iter (m_map.right.end()); count-- > 0 && iter != m_map.right.begin(); ++pruned) { --iter; beast::IP::Endpoint const& endpoint (iter->get_left()); Entry const& entry (iter->get_right()); JLOG(m_journal.trace()) << beast::leftw (18) << "Bootcache pruned" << endpoint << " at valence " << entry.valence(); iter = m_map.right.erase (iter); } JLOG(m_journal.debug()) << beast::leftw (18) << "Bootcache pruned " << pruned << " entries total"; }
/** Performs early sanity checks on the account and fee fields */ NotTEC preflight1 (PreflightContext const& ctx) { auto const ret = preflight0(ctx); if (!isTesSuccess(ret)) return ret; auto const id = ctx.tx.getAccountID(sfAccount); if (id == beast::zero) { JLOG(ctx.j.warn()) << "preflight1: bad account id"; return temBAD_SRC_ACCOUNT; } // No point in going any further if the transaction fee is malformed. auto const fee = ctx.tx.getFieldAmount (sfFee); if (!fee.native () || fee.negative () || !isLegalAmount (fee.xrp ())) { JLOG(ctx.j.debug()) << "preflight1: invalid fee"; return temBAD_FEE; } auto const spk = ctx.tx.getSigningPubKey(); if (!spk.empty () && !publicKeyType (makeSlice (spk))) { JLOG(ctx.j.debug()) << "preflight1: invalid signing key"; return temBAD_SIGNATURE; } return tesSUCCESS; }
TER CancelOffer::preflight (PreflightContext const& ctx) { auto const ret = preflight1 (ctx); if (!isTesSuccess (ret)) return ret; auto const uTxFlags = ctx.tx.getFlags(); if (uTxFlags & tfUniversalMask) { JLOG(ctx.j.trace) << "Malformed transaction: " << "Invalid flags set."; return temINVALID_FLAG; } auto const seq = ctx.tx.getFieldU32 (sfOfferSequence); if (! seq) { JLOG(ctx.j.trace) << "CancelOffer::preflight: missing sequence"; return temBAD_SEQUENCE; } return preflight2(ctx); }
void ManifestCache::load ( DatabaseCon& dbCon, std::string const& dbTable) { // Load manifests stored in database std::string const sql = "SELECT RawData FROM " + dbTable + ";"; auto db = dbCon.checkoutDb (); soci::blob sociRawData (*db); soci::statement st = (db->prepare << sql, soci::into (sociRawData)); st.execute (); while (st.fetch ()) { std::string serialized; convert (sociRawData, serialized); if (auto mo = Manifest::make_Manifest (std::move (serialized))) { if (!mo->verify()) { JLOG(j_.warn()) << "Unverifiable manifest in db"; continue; } applyManifest (std::move(*mo)); } else { JLOG(j_.warn()) << "Malformed manifest in database"; } } }
void Bootcache::load () { clear(); auto const n (m_store.load ( [this](beast::IP::Endpoint const& endpoint, int valence) { auto const result (this->m_map.insert ( value_type (endpoint, valence))); if (! result.second) { JLOG(this->m_journal.error()) << beast::leftw (18) << "Bootcache discard " << endpoint; } })); if (n > 0) { JLOG(m_journal.info()) << beast::leftw (18) << "Bootcache loaded " << n << ((n > 1) ? " addresses" : " address"); prune (); } }
std::pair<TER, bool> doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view) { if (preclaimResult.view.seq() != view.seq()) { // Logic error from the caller. Don't have enough // info to recover. return{ tefEXCEPTION, false }; } try { if (!preclaimResult.likelyToClaimFee) return{ preclaimResult.ter, false }; ApplyContext ctx(app, view, preclaimResult.tx, preclaimResult.ter, preclaimResult.baseFee, preclaimResult.flags, preclaimResult.j); if (view.txExists (ctx.tx.getTransactionID ())) { JLOG (preclaimResult.j.warning) << "transaction duplicates!"; return {tefALREADY, false}; } return invoke_apply(ctx); } catch (std::exception const& e) { JLOG(preclaimResult.j.fatal) << "apply: " << e.what(); return { tefEXCEPTION, false }; } }
TER PathCursor::liquidity () const { TER resultCode = tecPATH_DRY; PathCursor pc = *this; pathState_.resetView (rippleCalc_.view); for (pc.nodeIndex_ = pc.nodeSize(); pc.nodeIndex_--; ) { JLOG (j_.trace()) << "reverseLiquidity>" << " nodeIndex=" << pc.nodeIndex_ << ".issue_.account=" << to_string (pc.node().issue_.account); resultCode = pc.reverseLiquidity(); if (!pc.node().transferRate_) return tefINTERNAL; JLOG (j_.trace()) << "reverseLiquidity< " << "nodeIndex=" << pc.nodeIndex_ << " resultCode=" << transToken (resultCode) << " transferRate_=" << *pc.node().transferRate_ << ": " << resultCode; if (resultCode != tesSUCCESS) break; } // VFALCO-FIXME this generates errors // JLOG (j_.trace()) // << "nextIncrement: Path after reverse: " << pathState_.getJson (); if (resultCode != tesSUCCESS) return resultCode; pathState_.resetView (rippleCalc_.view); for (pc.nodeIndex_ = 0; pc.nodeIndex_ < pc.nodeSize(); ++pc.nodeIndex_) { JLOG (j_.trace()) << "forwardLiquidity> nodeIndex=" << nodeIndex_; resultCode = pc.forwardLiquidity(); if (resultCode != tesSUCCESS) return resultCode; JLOG (j_.trace()) << "forwardLiquidity<" << " nodeIndex:" << pc.nodeIndex_ << " resultCode:" << resultCode; if (pathState_.isDry()) resultCode = tecPATH_DRY; } return resultCode; }
TER SetTrust::preflight (PreflightContext const& ctx) { auto const ret = preflight1 (ctx); if (!isTesSuccess (ret)) return ret; auto& tx = ctx.tx; auto& j = ctx.j; std::uint32_t const uTxFlags = tx.getFlags (); if (uTxFlags & tfTrustSetMask) { JLOG(j.trace) << "Malformed transaction: Invalid flags set."; return temINVALID_FLAG; } STAmount const saLimitAmount (tx.getFieldAmount (sfLimitAmount)); if (!isLegalNet (saLimitAmount)) return temBAD_AMOUNT; if (saLimitAmount.native ()) { JLOG(j.trace) << "Malformed transaction: specifies native limit " << saLimitAmount.getFullText (); return temBAD_LIMIT; } if (badCurrency() == saLimitAmount.getCurrency ()) { JLOG(j.trace) << "Malformed transaction: specifies XRP as IOU"; return temBAD_CURRENCY; } if (saLimitAmount < zero) { JLOG(j.trace) << "Malformed transaction: Negative credit limit."; return temBAD_LIMIT; } // Check if destination makes sense. auto const& issuer = saLimitAmount.getIssuer (); if (!issuer || issuer == noAccount()) { JLOG(j.trace) << "Malformed transaction: no destination account."; return temDST_NEEDED; } return preflight2 (ctx); }
bool ManifestCache::load ( DatabaseCon& dbCon, std::string const& dbTable, std::string const& configManifest, std::vector<std::string> const& configRevocation) { load (dbCon, dbTable); if (! configManifest.empty()) { auto mo = Manifest::make_Manifest ( beast::detail::base64_decode(configManifest)); if (! mo) { JLOG (j_.error()) << "Malformed validator_token in config"; return false; } if (mo->revoked()) { JLOG (j_.warn()) << "Configured manifest revokes public key"; } if (applyManifest (std::move(*mo)) == ManifestDisposition::invalid) { JLOG (j_.error()) << "Manifest in config was rejected"; return false; } } if (! configRevocation.empty()) { std::string revocationStr; revocationStr.reserve ( std::accumulate (configRevocation.cbegin(), configRevocation.cend(), std::size_t(0), [] (std::size_t init, std::string const& s) { return init + s.size(); })); for (auto const& line : configRevocation) revocationStr += beast::rfc2616::trim(line); auto mo = Manifest::make_Manifest ( beast::detail::base64_decode(revocationStr)); if (! mo || ! mo->revoked() || applyManifest (std::move(*mo)) == ManifestDisposition::invalid) { JLOG (j_.error()) << "Invalid validator key revocation in config"; return false; } } return true; }
TER SetSignerList::validateQuorumAndSignerEntries ( std::uint32_t quorum, std::vector<SignerEntries::SignerEntry> const& signers, AccountID const& account, beast::Journal j) { // Reject if there are too many or too few entries in the list. { std::size_t const signerCount = signers.size (); if ((signerCount < STTx::minMultiSigners) || (signerCount > STTx::maxMultiSigners)) { JLOG(j.trace) << "Too many or too few signers in signer list."; return temMALFORMED; } } // Make sure there are no duplicate signers. assert(std::is_sorted(signers.begin(), signers.end())); if (std::adjacent_find ( signers.begin (), signers.end ()) != signers.end ()) { JLOG(j.trace) << "Duplicate signers in signer list"; return temBAD_SIGNER; } // Make sure no signers reference this account. Also make sure the // quorum can be reached. std::uint64_t allSignersWeight (0); for (auto const& signer : signers) { std::uint32_t const weight = signer.weight; if (weight <= 0) { JLOG(j.trace) << "Every signer must have a positive weight."; return temBAD_WEIGHT; } allSignersWeight += signer.weight; if (signer.account == account) { JLOG(j.trace) << "A signer may not self reference account."; return temBAD_SIGNER; } // Don't verify that the signer accounts exist. Non-existent accounts // may be phantom accounts (which are permitted). } if ((quorum <= 0) || (allSignersWeight < quorum)) { JLOG(j.trace) << "Quorum is unreachable"; return temBAD_QUORUM; } return tesSUCCESS; }
void stop () override { stop_async (); JLOG(m_journal.debug()) << "Waiting to stop"; std::unique_lock<std::mutex> lk{m_mut}; m_cv.wait(lk, [this]{return m_asyncHandlersCompleted;}); lk.unlock(); JLOG(m_journal.debug()) << "Stopped"; }
STPathSet::STPathSet (SerialIter& sit, SField const& name) : STBase(name) { std::vector<STPathElement> path; for(;;) { int iType = sit.get8 (); if (iType == STPathElement::typeNone || iType == STPathElement::typeBoundary) { if (path.empty ()) { JLOG (debugLog().error()) << "Empty path in pathset"; Throw<std::runtime_error> ("empty path"); } push_back (path); path.clear (); if (iType == STPathElement::typeNone) return; } else if (iType & ~STPathElement::typeAll) { JLOG (debugLog().error()) << "Bad path element " << iType << " in pathset"; Throw<std::runtime_error> ("bad path element"); } else { auto hasAccount = iType & STPathElement::typeAccount; auto hasCurrency = iType & STPathElement::typeCurrency; auto hasIssuer = iType & STPathElement::typeIssuer; AccountID account; Currency currency; AccountID issuer; if (hasAccount) account.copyFrom (sit.get160 ()); if (hasCurrency) currency.copyFrom (sit.get160 ()); if (hasIssuer) issuer.copyFrom (sit.get160 ()); path.emplace_back (account, currency, issuer, hasCurrency); } } }
bool JMP3::setLoop(bool loop) { JLOG("Start JMP3::setLoop"); if (!init_done) { JLOG("JMP3::setLoop called but init_done is false!"); return false; } #ifdef MP3_SUPPORT sceMp3SetLoopNum(m_mp3Handle, (loop == true) ? -1 : 0); #endif return (m_loop = loop); JLOG("End JMP3::setLoop"); }
/** Process a single ledger @param ledgerIndex The index of the ledger to process. @param ledgerHash The known correct hash of the ledger. @param doNodes Ensure all ledger nodes are in the node db. @param doTxns Reprocess (account) transactions to SQL databases. @return `true` if the ledger was cleaned. */ bool doLedger( LedgerIndex const& ledgerIndex, LedgerHash const& ledgerHash, bool doNodes, bool doTxns) { auto nodeLedger = app_.getInboundLedgers().acquire ( ledgerHash, ledgerIndex, InboundLedger::fcGENERIC); if (!nodeLedger) { JLOG (j_.debug()) << "Ledger " << ledgerIndex << " not available"; app_.getLedgerMaster().clearLedger (ledgerIndex); app_.getInboundLedgers().acquire( ledgerHash, ledgerIndex, InboundLedger::fcGENERIC); return false; } auto dbLedger = loadByIndex(ledgerIndex, app_); if (! dbLedger || (dbLedger->info().hash != ledgerHash) || (dbLedger->info().parentHash != nodeLedger->info().parentHash)) { // Ideally we'd also check for more than one ledger with that index JLOG (j_.debug()) << "Ledger " << ledgerIndex << " mismatches SQL DB"; doTxns = true; } if(! app_.getLedgerMaster().fixIndex(ledgerIndex, ledgerHash)) { JLOG (j_.debug()) << "ledger " << ledgerIndex << " had wrong entry in history"; doTxns = true; } if (doNodes && !nodeLedger->walkLedger(app_.journal ("Ledger"))) { JLOG (j_.debug()) << "Ledger " << ledgerIndex << " is missing nodes"; app_.getLedgerMaster().clearLedger (ledgerIndex); app_.getInboundLedgers().acquire( ledgerHash, ledgerIndex, InboundLedger::fcGENERIC); return false; } if (doTxns && !pendSaveValidated(app_, nodeLedger, true, false)) { JLOG (j_.debug()) << "Failed to save ledger " << ledgerIndex; return false; } return true; }
// - A ripple nodes output issuer must be the node's account or the next node's // account. // - Offers can only go directly to another offer if the currency and issuer are // an exact match. // - Real issuers must be specified for non-XRP. TER PathState::pushImpliedNodes ( AccountID const& account, // --> Delivering to this account. Currency const& currency, // --> Delivering this currency. AccountID const& issuer) // --> Delivering this issuer. { TER resultCode = tesSUCCESS; JLOG (j_.trace) << "pushImpliedNodes>" << " " << account << " " << currency << " " << issuer; if (nodes_.back ().issue_.currency != currency) { // Currency is different, need to convert via an offer from an order // book. xrpAccount() does double duty as signaling "this is an order // book". // Corresponds to "Implies an offer directory" in the diagram, currently // at http://goo.gl/Uj3HAB. auto type = isXRP(currency) ? STPathElement::typeCurrency : STPathElement::typeCurrency | STPathElement::typeIssuer; // The offer's output is what is now wanted. // xrpAccount() is a placeholder for offers. resultCode = pushNode (type, xrpAccount(), currency, issuer); } // For ripple, non-XRP, ensure the issuer is on at least one side of the // transaction. if (resultCode == tesSUCCESS && !isXRP(currency) && nodes_.back ().account_ != issuer // Previous is not issuing own IOUs. && account != issuer) // Current is not receiving own IOUs. { // Need to ripple through issuer's account. // Case "Implies an another node: (pushImpliedNodes)" in the document. // Intermediate account is the needed issuer. resultCode = pushNode ( STPathElement::typeAll, issuer, currency, issuer); } JLOG (j_.trace) << "pushImpliedNodes< : " << transToken (resultCode); return resultCode; }
void CAlarmMachine::SetAdemcoEvent(EventSource resource, int ademco_event, int zone, int subzone, const time_t& timestamp, const time_t& recv_time, const ademco::char_array_ptr& xdata ) { AUTO_LOG_FUNCTION; std::lock_guard<std::mutex> lock(_lock4AdemcoEventList); ademco::AdemcoEventPtr ademcoEvent = std::make_shared<AdemcoEvent>(resource, ademco_event, zone, subzone, timestamp, recv_time, xdata); if (EVENT_PRIVATE_EVENT_BASE <= ademco_event && ademco_event <= EVENT_PRIVATE_EVENT_MAX) { // 内部事件立即处理 } else { #ifdef _DEBUG wchar_t wtime[32] = { 0 }; struct tm tmtm; localtime_s(&tmtm, &recv_time); wcsftime(wtime, 32, L"%Y-%m-%d %H:%M:%S", &tmtm); JLOG(L"param: %s\n", wtime); #endif time_t now = time(nullptr); auto iter = _ademcoEventFilter.begin(); while (iter != _ademcoEventFilter.end()) { const ademco::AdemcoEventPtr& oldEvent = *iter; #ifdef _DEBUG localtime_s(&tmtm, &now); wcsftime(wtime, 32, L"%Y-%m-%d %H:%M:%S", &tmtm); JLOG(L"now: %s\n", wtime); localtime_s(&tmtm, &oldEvent->_recv_time); wcsftime(wtime, 32, L"%Y-%m-%d %H:%M:%S", &tmtm); JLOG(L"old: %s\n", wtime); #endif if (now - oldEvent->_recv_time >= 6) { _ademcoEventFilter.erase(iter); iter = _ademcoEventFilter.begin(); continue; } else if (oldEvent->operator== (*ademcoEvent)) { JLOG(L"same AdemcoEvent, delete it. ademco_id %06d, event %04d, zone %03d, gg %02d\n", _ademco_id, ademcoEvent->_event, ademcoEvent->_zone, ademcoEvent->_sub_zone); _ademcoEventFilter.erase(iter); _ademcoEventFilter.push_back(ademcoEvent); return; } iter++; } _ademcoEventFilter.push_back(ademcoEvent); } HandleAdemcoEvent(ademcoEvent); }
NotTEC Transactor::checkSingleSign (PreclaimContext const& ctx) { auto const id = ctx.tx.getAccountID(sfAccount); auto const sle = ctx.view.read( keylet::account(id)); auto const hasAuthKey = sle->isFieldPresent (sfRegularKey); // Consistency: Check signature & verify the transaction's signing // public key is authorized for signing. auto const spk = ctx.tx.getSigningPubKey(); if (!publicKeyType (makeSlice (spk))) { JLOG(ctx.j.trace()) << "checkSingleSign: signing public key type is unknown"; return tefBAD_AUTH; // FIXME: should be better error! } auto const pkAccount = calcAccountID ( PublicKey (makeSlice (spk))); if (pkAccount == id) { // Authorized to continue. if (sle->isFlag(lsfDisableMaster)) return tefMASTER_DISABLED; } else if (hasAuthKey && (pkAccount == sle->getAccountID (sfRegularKey))) { // Authorized to continue. } else if (hasAuthKey) { JLOG(ctx.j.trace()) << "checkSingleSign: Not authorized to use account."; return tefBAD_AUTH; } else { JLOG(ctx.j.trace()) << "checkSingleSign: Not authorized to use account."; return tefBAD_AUTH_MASTER; } return tesSUCCESS; }
/** Returns the hash of the specified ledger. @param ledgerIndex The index of the desired ledger. @param referenceLedger [out] An optional known good subsequent ledger. @return The hash of the ledger. This will be all-bits-zero if not found. */ LedgerHash getHash( LedgerIndex const& ledgerIndex, std::shared_ptr<ReadView const>& referenceLedger) { LedgerHash ledgerHash; if (!referenceLedger || (referenceLedger->info().seq < ledgerIndex)) { referenceLedger = app_.getLedgerMaster().getValidatedLedger(); if (!referenceLedger) { JLOG (j_.warn()) << "No validated ledger"; return ledgerHash; // Nothing we can do. No validated ledger. } } if (referenceLedger->info().seq >= ledgerIndex) { // See if the hash for the ledger we need is in the reference ledger ledgerHash = getLedgerHash(referenceLedger, ledgerIndex); if (ledgerHash.isZero()) { // No. Try to get another ledger that might have the hash we // need: compute the index and hash of a ledger that will have // the hash we need. LedgerIndex refIndex = getCandidateLedger (ledgerIndex); LedgerHash refHash = getLedgerHash (referenceLedger, refIndex); bool const nonzero (refHash.isNonZero ()); assert (nonzero); if (nonzero) { // We found the hash and sequence of a better reference // ledger. referenceLedger = app_.getInboundLedgers().acquire( refHash, refIndex, InboundLedger::fcGENERIC); if (referenceLedger) ledgerHash = getLedgerHash( referenceLedger, ledgerIndex); } } } else JLOG (j_.warn()) << "Validated ledger is prior to target ledger"; return ledgerHash; }
bool JMP3::loadModules() { JLOG("loading Audio modules"); #ifdef MP3_SUPPORT int loadAvCodec = sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC); if (loadAvCodec < 0) { return false; } int loadMp3 = sceUtilityLoadModule(PSP_MODULE_AV_MP3); if (loadMp3 < 0) { return false; } JLOG("Audio modules loaded"); #endif return true; }
int CAlarmMachine::Send(const char* buff, size_t buff_size) { //AUTO_LOG_FUNCTION; timeval tv = { 0, 10000 }; fd_set fdWrite; int nRet = 0; do { FD_ZERO(&fdWrite); FD_SET(m_socket, &fdWrite); nRet = select(m_socket + 1, NULL, &fdWrite, NULL, &tv); } while (nRet <= 0 && !FD_ISSET(m_socket, &fdWrite)); nRet = send(m_socket, buff, buff_size, 0); if (nRet <= 0) { JLOG(_T("CClientmachine::Send ret <= 0, ret %d"), nRet); OnConnectionLost(); } else { } return nRet; }
std::shared_ptr<Ledger const> acquire(uint256 const& hash, std::uint32_t seq, InboundLedger::Reason reason) override { assert(hash.isNonZero()); assert(reason != InboundLedger::Reason::SHARD || (seq != 0 && app_.getShardStore())); if (isStopping()) return {}; bool isNew = true; std::shared_ptr<InboundLedger> inbound; { ScopedLockType sl(mLock); auto it = mLedgers.find(hash); if (it != mLedgers.end()) { isNew = false; inbound = it->second; } else { inbound = std::make_shared <InboundLedger>( app_, hash, seq, reason, std::ref(m_clock)); mLedgers.emplace(hash, inbound); inbound->init(sl); ++mCounter; } } if (inbound->isFailed()) return {}; if (! isNew) inbound->update(seq); if (! inbound->isComplete()) return {}; if (reason == InboundLedger::Reason::HISTORY) { if (inbound->getLedger()->stateMap().family().isShardBacked()) app_.getNodeStore().copyLedger(inbound->getLedger()); } else if (reason == InboundLedger::Reason::SHARD) { auto shardStore = app_.getShardStore(); if (!shardStore) { JLOG(j_.error()) << "Acquiring shard with no shard store available"; return {}; } if (inbound->getLedger()->stateMap().family().isShardBacked()) shardStore->setStored(inbound->getLedger()); else shardStore->copyLedger(inbound->getLedger()); } return inbound->getLedger(); }
/** Check if a sequence of three accounts violates the no ripple constrains [first] -> [second] -> [third] Disallowed if 'second' set no ripple on [first]->[second] and [second]->[third] */ TER PathState::checkNoRipple ( AccountID const& firstAccount, AccountID const& secondAccount, // This is the account whose constraints we are checking AccountID const& thirdAccount, Currency const& currency) { // fetch the ripple lines into and out of this node SLE::pointer sleIn = view().peek ( keylet::line(firstAccount, secondAccount, currency)); SLE::pointer sleOut = view().peek ( keylet::line(secondAccount, thirdAccount, currency)); if (!sleIn || !sleOut) { terStatus = terNO_LINE; } else if ( sleIn->getFieldU32 (sfFlags) & ((secondAccount > firstAccount) ? lsfHighNoRipple : lsfLowNoRipple) && sleOut->getFieldU32 (sfFlags) & ((secondAccount > thirdAccount) ? lsfHighNoRipple : lsfLowNoRipple)) { JLOG (j_.info) << "Path violates noRipple constraint between " << firstAccount << ", " << secondAccount << " and " << thirdAccount; terStatus = terNO_RIPPLE; } return terStatus; }
void Bootcache::on_failure (beast::IP::Endpoint const& endpoint) { auto result (m_map.insert ( value_type (endpoint, -1))); if (result.second) { prune(); } else { Entry entry (result.first->right); if (entry.valence() > 0) entry.valence() = 0; --entry.valence(); m_map.erase (result.first); result = m_map.insert ( value_type (endpoint, entry)); assert (result.second); } Entry const& entry (result.first->right); auto const n (std::abs (entry.valence())); JLOG(m_journal.debug()) << beast::leftw (18) << "Bootcache failed " << endpoint << " with " << n << ((n > 1) ? " attempts" : " attempt"); flagForUpdate(); }
PreclaimResult preclaim (PreflightResult const& preflightResult, Application& app, OpenView const& view) { boost::optional<PreclaimContext const> ctx; if (preflightResult.rules != view.rules()) { auto secondFlight = preflight(app, view.rules(), preflightResult.tx, preflightResult.flags, preflightResult.j); ctx.emplace(app, view, secondFlight.ter, secondFlight.tx, secondFlight.flags, secondFlight.j); } else { ctx.emplace( app, view, preflightResult.ter, preflightResult.tx, preflightResult.flags, preflightResult.j); } try { if (ctx->preflightResult != tesSUCCESS) return { *ctx, ctx->preflightResult, 0 }; return{ *ctx, invoke_preclaim(*ctx) }; } catch (std::exception const& e) { JLOG(ctx->j.fatal) << "apply: " << e.what(); return{ *ctx, tefEXCEPTION, 0 }; } }
// Build a ledger from consensus transactions std::shared_ptr<Ledger> buildLedger( std::shared_ptr<Ledger const> const& parent, NetClock::time_point closeTime, const bool closeTimeCorrect, NetClock::duration closeResolution, SHAMap const& txs, Application& app, CanonicalTXSet& retriableTxs, beast::Journal j) { JLOG(j.debug()) << "Report: TxSt = " << txs.getHash().as_uint256() << ", close " << closeTime.time_since_epoch().count() << (closeTimeCorrect ? "" : " (incorrect)"); return buildLedgerImpl( parent, closeTime, closeTimeCorrect, closeResolution, app, j, [&](OpenView& accum, std::shared_ptr<Ledger> const& buildLCL) { retriableTxs = applyTransactions(app, txs, accum, buildLCL, j); }); }
void LoadManager::onStart () { JLOG(journal_.debug) << "Starting"; assert (! thread_.joinable()); thread_ = std::thread {&LoadManager::run, this}; }
ConnectAttempt::~ConnectAttempt() { if (slot_ != nullptr) overlay_.peerFinder().on_closed(slot_); JLOG(journal_.trace()) << "~ConnectAttempt"; }
bool LoadFeeTrack::raiseLocalFee () { ScopedLockType sl (mLock); if (++raiseCount < 2) return false; std::uint32_t origFee = mLocalTxnLoadFee; // make sure this fee takes effect if (mLocalTxnLoadFee < mRemoteTxnLoadFee) mLocalTxnLoadFee = mRemoteTxnLoadFee; // Increase slowly mLocalTxnLoadFee += (mLocalTxnLoadFee / lftFeeIncFraction); if (mLocalTxnLoadFee > lftFeeMax) mLocalTxnLoadFee = lftFeeMax; if (origFee == mLocalTxnLoadFee) return false; JLOG(m_journal.debug()) << "Local load fee raised from " << origFee << " to " << mLocalTxnLoadFee; return true; }