Ripple的PeerFinder

作者: SwordShield | 来源:发表于2018-02-24 17:58 被阅读24次

    Ripple的节点发现过程有两条线:

    • 一条是读取db文件夹下的peerfinder.sqlite文件,这是一个sqlite文件,里面存了前次运行时的active_peer,最多存20个记录
    • 另一条,直接读取配置文件中的ips/ips_fixed

    peerfinder.sqlite路径:

    Overlay对象初始化过程:

    Application::setUp->
    OverlayImpl::make_Overlay->
    PeerfinderManager::make_Manager->
    ManagerImp::ManagerImp()->
    Logic::Logic()->
    Bootcache::Bootcache()->
    StoreSqdb::StoreSqdb()
    

    StoreSqdb::load 读取peerfinder.sqlite并存储到Bootcache的map中

    对于每一个ip:port,执行下面的操作:

    OverlayImpl::Timer::on_timer->
    OverlayImpl::autoConnect->
    OverlayImpl::connect->
    ConnectAttempt::ConnectAttempt,ConnectAttempt::run()->
    ConnectAttempt::onConnect->
    ConnectAttempt::onHandshake->
    ConnectAttempt::makeRequest->
    ConnectAttempt::processResponse->
    overlay_.add_active (peer)
    

    直接读取配置的ips/ips_fixed:

    auto bootstrapIps = app_.config().IPS.empty()
        ? app_.config().IPS_FIXED
        : app_.config().IPS;
    if (bootstrapIps.empty ())
        bootstrapIps.push_back ("r.ripple.com 51235");
    

    也就是说配了ips/ips_fixed,会去读取配置的ip:port

    如果没配的话,会去连接ripple的官方节点:r.ripple.com 51235

    读取完引导节点后会调用下面的过程:

    OverlayImpl::onPrepare()->
    PeerfinderManager::addFallbackStrings()->
    Logic::addStaticSource->
    Logic::fetch->
    Logic::addBootcacheAddresses
    Bootcache::insert
    

    相关文章

      网友评论

        本文标题:Ripple的PeerFinder

        本文链接:https://www.haomeiwen.com/subject/yzkcxftx.html