区块链 Ripple

Ripple的PeerFinder

2018-02-24  本文已影响24人  SwordShield

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

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
上一篇下一篇

猜你喜欢

热点阅读