예제 #1
0
LedgerHistory::LedgerHistory (
    beast::insight::Collector::ptr const& collector)
    : collector_ (collector)
    , mismatch_counter_ (collector->make_counter ("ledger.history", "mismatch"))
    , m_ledgers_by_hash ("LedgerCache", CACHED_LEDGER_NUM, CACHED_LEDGER_AGE,
        get_seconds_clock (), deprecatedLogs().journal("TaggedCache"))
    , m_consensus_validated ("ConsensusValidated", 64, 300,
        get_seconds_clock (), deprecatedLogs().journal("TaggedCache"))
{
}
예제 #2
0
ConsensusImp::ConsensusImp ()
    : journal_ (deprecatedLogs().journal("Consensus"))
    , feeVote_ (make_FeeVote (setup_FeeVote (getConfig().section ("voting")),
        deprecatedLogs().journal("FeeVote")))
    , proposing_ (false)
    , validating_ (false)
    , lastCloseProposers_ (0)
    , lastCloseConvergeTook_ (1000 * LEDGER_IDLE_INTERVAL)
    , lastValidationTimestamp_ (0)
    , lastCloseTime_ (0)
{
}
예제 #3
0
Json::Value doLogLevel (RPC::Context& context)
{
    // log_level
    if (!context.params.isMember (jss::severity))
    {
        // get log severities
        Json::Value ret (Json::objectValue);
        Json::Value lev (Json::objectValue);

        lev[jss::base] =
                Logs::toString(Logs::fromSeverity(deprecatedLogs().severity()));
        std::vector< std::pair<std::string, std::string> > logTable (
            deprecatedLogs().partition_severities());
        typedef std::map<std::string, std::string>::value_type stringPair;
        for (auto const& it : logTable)
            lev[it.first] = it.second;

        ret[jss::levels] = lev;
        return ret;
    }

    LogSeverity const sv (
        Logs::fromString (context.params[jss::severity].asString ()));

    if (sv == lsINVALID)
        return rpcError (rpcINVALID_PARAMS);

    auto severity = Logs::toSeverity(sv);
    // log_level severity
    if (!context.params.isMember (jss::partition))
    {
        // set base log severity
        deprecatedLogs().severity(severity);
        return Json::objectValue;
    }

    // log_level partition severity base?
    if (context.params.isMember (jss::partition))
    {
        // set partition severity
        std::string partition (context.params[jss::partition].asString ());

        if (boost::iequals (partition, "base"))
            deprecatedLogs().severity (severity);
        else
            deprecatedLogs().get(partition).severity(severity);

        return Json::objectValue;
    }

    return rpcError (rpcINVALID_PARAMS);
}
예제 #4
0
void
OverlayImpl::connect (beast::IP::Endpoint const& remote_endpoint)
{
    assert(work_);

    auto usage = resourceManager().newOutboundEndpoint (remote_endpoint);
    if (usage.disconnect())
    {
        if (journal_.info) journal_.info <<
            "Over resource limit: " << remote_endpoint;
        return;
    }
    
    auto const slot = peerFinder().new_outbound_slot(remote_endpoint);
    if (slot == nullptr)
    {
        if (journal_.debug) journal_.debug <<
            "Connect: No slot for " << remote_endpoint;
        return;
    }

    auto const p = std::make_shared<ConnectAttempt>(
        io_service_, beast::IPAddressConversion::to_asio_endpoint(remote_endpoint),
            usage, setup_.context, next_id_++, slot,
                deprecatedLogs().journal("Peer"), *this);

    std::lock_guard<decltype(mutex_)> lock(mutex_);
    list_.emplace(p.get(), p);
    p->run();
}
예제 #5
0
ServerHandlerImp::ServerHandlerImp (Stoppable& parent, JobQueue& jobQueue,
    NetworkOPs& networkOPs, Resource::Manager& resourceManager,
        RPC::Setup const& setup)
    : ServerHandler (parent)
    , m_resourceManager (resourceManager)
    , m_journal (deprecatedLogs().journal("Server"))
    , m_jobQueue (jobQueue)
    , m_networkOPs (networkOPs)
    , m_server (*this, deprecatedLogs().journal("Server"))
    , setup_ (setup)
{
    if (setup_.secure)
        m_context.reset (RippleSSLContext::createAuthenticated (
            setup_.ssl_key, setup_.ssl_cert, setup_.ssl_chain));
    else
        m_context.reset (RippleSSLContext::createBare());
}
예제 #6
0
 SetTrust (
     SerializedTransaction const& txn,
     TransactionEngineParams params,
     TransactionEngine* engine)
     : Transactor (
         txn,
         params,
         engine,
         deprecatedLogs().journal("SetTrust"))
 {
 }
예제 #7
0
파일: LogLevel.cpp 프로젝트: BobWay/rippled
Json::Value doLogLevel (RPC::Context& context)
{
    // log_level
    if (!context.params.isMember ("severity"))
    {
        // get log severities
        Json::Value ret (Json::objectValue);
        Json::Value lev (Json::objectValue);

        lev["base"] =
                Logs::toString(Logs::fromSeverity(deprecatedLogs().severity()));
        std::vector< std::pair<std::string, std::string> > logTable (
            deprecatedLogs().partition_severities());
        typedef std::map<std::string, std::string>::value_type stringPair;
        BOOST_FOREACH (const stringPair & it, logTable)
            lev[it.first] = it.second;

        ret["levels"] = lev;
        return ret;
    }
예제 #8
0
CreateOffer::CreateOffer (
    SerializedTransaction const& txn,
    TransactionEngineParams params,
    TransactionEngine* engine)
    : Transactor (
        txn,
        params,
        engine,
        deprecatedLogs().journal("CreateOffer"))
{

}
예제 #9
0
    SetRegularKey (
        STTx const& txn,
        TransactionEngineParams params,
        TransactionEngine* engine)
        : Transactor (
            txn,
            params,
            engine,
            deprecatedLogs().journal("SetRegularKey"))
    {

    }
예제 #10
0
파일: Payment.cpp 프로젝트: xdv/divvyd
    Payment (
        STTx const& txn,
        TransactionEngineParams params,
        TransactionEngine* engine)
        : Transactor (
            txn,
            params,
            engine,
            deprecatedLogs().journal("Payment"))
    {

    }
예제 #11
0
    CancelOffer (
        STTx const& txn,
        TransactionEngineParams params,
        TransactionEngine* engine)
        : Transactor (
            txn,
            params,
            engine,
            deprecatedLogs().journal("CancelOffer"))
    {

    }
예제 #12
0
    AddReferee(
        SerializedTransaction const& txn,
        TransactionEngineParams params,
        TransactionEngine* engine)
        : Transactor (
            txn,
            params,
            engine,
            deprecatedLogs().journal("AddReferee"))
    {

    }
예제 #13
0
namespace ripple {

// VFALCO TODO Remove this global and make it a member of the App
//             Use a dependency injection to give AcceptedLedger access.
//
TaggedCache <uint256, AcceptedLedger> AcceptedLedger::s_cache (
    "AcceptedLedger", 4, 60, get_seconds_clock (),
        deprecatedLogs().journal("TaggedCache"));

AcceptedLedger::AcceptedLedger (Ledger::ref ledger) : mLedger (ledger)
{
    SHAMap& txSet = *ledger->peekTransactionMap ();

    for (SHAMapItem::pointer item = txSet.peekFirstItem (); item;
         item = txSet.peekNextItem (item->getTag ()))
    {
        SerializerIterator sit (item->peekSerializer ());
        insert (std::make_shared<AcceptedLedgerTx> (ledger, std::ref (sit)));
    }
}

AcceptedLedger::pointer AcceptedLedger::makeAcceptedLedger (Ledger::ref ledger)
{
    AcceptedLedger::pointer ret = s_cache.fetch (ledger->getHash ());

    if (ret)
        return ret;

    ret = AcceptedLedger::pointer (new AcceptedLedger (ledger));
    s_cache.canonicalize (ledger->getHash (), ret);
    return ret;
}

void AcceptedLedger::insert (AcceptedLedgerTx::ref at)
{
    assert (mMap.find (at->getIndex ()) == mMap.end ());
    mMap.insert (std::make_pair (at->getIndex (), at));
}

AcceptedLedgerTx::pointer AcceptedLedger::getTxn (int i) const
{
    map_t::const_iterator it = mMap.find (i);

    if (it == mMap.end ())
        return AcceptedLedgerTx::pointer ();

    return it->second;
}

} // ripple
예제 #14
0
OverlayImpl::OverlayImpl (
    Setup const& setup,
    Stoppable& parent,
    ServerHandler& serverHandler,
    Resource::Manager& resourceManager,
    Resolver& resolver,
    boost::asio::io_service& io_service,
    BasicConfig const& config)
    : Overlay (parent)
    , io_service_ (io_service)
    , work_ (boost::in_place(std::ref(io_service_)))
    , strand_ (io_service_)
    , setup_(setup)
    , journal_ (deprecatedLogs().journal("Overlay"))
    , serverHandler_(serverHandler)
    , m_resourceManager (resourceManager)
    , m_peerFinder (PeerFinder::make_Manager (*this, io_service,
        get_seconds_clock(), deprecatedLogs().journal("PeerFinder"), config))
    , m_resolver (resolver)
    , next_id_(1)
    , timer_count_(0)
{
    beast::PropertyStream::Source::add (m_peerFinder.get());
}
예제 #15
0
 InboundTransactionsImp (
         clock_type& clock,
         Stoppable& parent,
         beast::insight::Collector::ptr const& collector,
         std::function <void (uint256 const&,
             std::shared_ptr <SHAMap> const&)> gotSet)
     : Stoppable ("InboundTransactions", parent)
     , m_clock (clock)
     , m_seq (0)
     , m_zeroSet (m_map[uint256()])
     , m_gotSet (std::move (gotSet))
 {
     m_zeroSet.mSet = std::make_shared<SHAMap> (
         SHAMapType::TRANSACTION, uint256(),
         getApp().family(), deprecatedLogs().journal("SHAMap"));
     m_zeroSet.mSet->setUnbacked();
 }
예제 #16
0
TransactionMaster::TransactionMaster ()
    : mCache ("TransactionCache", 65536, 1800, get_seconds_clock (),
        deprecatedLogs().journal("TaggedCache"))
{
}
예제 #17
0
Json::Value doLogRotate (RPC::Context&)
{
    return RPC::makeObjectValue (deprecatedLogs().rotate());
}
예제 #18
0
Handoff
OverlayImpl::onHandoff (std::unique_ptr <beast::asio::ssl_bundle>&& ssl_bundle,
    beast::http::message&& request,
        endpoint_type remote_endpoint)
{
    auto const id = next_id_++;
    beast::WrappedSink sink (deprecatedLogs()["Peer"], makePrefix(id));
    beast::Journal journal (sink);

    Handoff handoff;
    if (processRequest(request, handoff))
        return handoff;
    if (! isPeerUpgrade(request))
        return handoff;

    handoff.moved = true;

    if (journal.trace) journal.trace <<
        "Peer connection upgrade from " << remote_endpoint;

    error_code ec;
    auto const local_endpoint (ssl_bundle->socket.local_endpoint(ec));
    if (ec)
    {
        if (journal.trace) journal.trace <<
            remote_endpoint << " failed: " << ec.message();
        return handoff;
    }

    auto consumer = m_resourceManager.newInboundEndpoint(
        beast::IPAddressConversion::from_asio(remote_endpoint));
    if (consumer.disconnect())
        return handoff;

    auto const slot = m_peerFinder->new_inbound_slot (
        beast::IPAddressConversion::from_asio(local_endpoint),
            beast::IPAddressConversion::from_asio(remote_endpoint));

    if (slot == nullptr)
    {
        // self-connect, close
        handoff.moved = false;
        return handoff;
    }

    // TODO Validate HTTP request

    {
        auto const types = beast::rfc2616::split_commas(
            request.headers["Connect-As"]);
        if (std::find_if(types.begin(), types.end(),
                [](std::string const& s)
                {
                    return beast::ci_equal(s, "peer");
                }) == types.end())
        {
            handoff.moved = false;
            handoff.response = makeRedirectResponse(slot, request,
                remote_endpoint.address());
            handoff.keep_alive = request.keep_alive();
            return handoff;
        }
    }

    handoff.moved = true;
    bool success = true;

    protocol::TMHello hello;
    std::tie(hello, success) = parseHello (request, journal);
    if(! success)
        return handoff;

    uint256 sharedValue;
    std::tie(sharedValue, success) = makeSharedValue(
        ssl_bundle->stream.native_handle(), journal);
    if(! success)
        return handoff;

    RippleAddress publicKey;
    std::tie(publicKey, success) = verifyHello (hello,
        sharedValue, journal, getApp());
    if(! success)
        return handoff;

    std::string name;
    bool const cluster = getApp().getUNL().nodeInCluster(
        publicKey, name);
    
    auto const result = m_peerFinder->activate (slot,
        publicKey.toPublicKey(), cluster);
    if (result != PeerFinder::Result::success)
    {
        if (journal.trace) journal.trace <<
            "Peer " << remote_endpoint << " redirected, slots full";
        handoff.moved = false;
        handoff.response = makeRedirectResponse(slot, request,
            remote_endpoint.address());
        handoff.keep_alive = request.keep_alive();
        return handoff;
    }

    auto const peer = std::make_shared<PeerImp>(id,
        remote_endpoint, slot, std::move(request), hello, publicKey,
            consumer, std::move(ssl_bundle), *this);
    {
        // As we are not on the strand, run() must be called
        // while holding the lock, otherwise new I/O can be
        // queued after a call to stop().
        std::lock_guard <decltype(mutex_)> lock (mutex_);
        add(peer);
        peer->run();
    }
    handoff.moved = true;
    return handoff;
}