From edc8f16d2f388889c87b9668f6019146d78c1ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Malinowski?= Date: Mon, 4 Feb 2019 12:28:59 +0100 Subject: [PATCH] set peers from config as OUTBOUND by default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: RafaƂ Malinowski --- src/overlay/OverlayManagerImpl.cpp | 5 +++-- src/overlay/PeerManager.cpp | 21 ++++++++------------- src/overlay/PeerManager.h | 6 ++---- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/overlay/OverlayManagerImpl.cpp b/src/overlay/OverlayManagerImpl.cpp index 6f2b7f082f..402d2ba86b 100644 --- a/src/overlay/OverlayManagerImpl.cpp +++ b/src/overlay/OverlayManagerImpl.cpp @@ -304,8 +304,9 @@ void OverlayManagerImpl::storePeerList(std::vector const& list, bool setPreferred) { - auto typeUpgrade = setPreferred ? PeerManager::TypeUpdate::SET_PREFERRED - : PeerManager::TypeUpdate::KEEP; + auto typeUpgrade = setPreferred + ? PeerManager::TypeUpdate::SET_PREFERRED + : PeerManager::TypeUpdate::UPDATE_TO_OUTBOUND; for (auto const& peerStr : list) { diff --git a/src/overlay/PeerManager.cpp b/src/overlay/PeerManager.cpp index 76cf785dd0..02fc524f43 100644 --- a/src/overlay/PeerManager.cpp +++ b/src/overlay/PeerManager.cpp @@ -278,15 +278,6 @@ PeerManager::update(PeerRecord& peer, TypeUpdate type) { switch (type) { - case TypeUpdate::KEEP: - { - break; - } - case TypeUpdate::SET_INBOUND: - { - peer.mType = static_cast(PeerType::INBOUND); - break; - } case TypeUpdate::SET_OUTBOUND: { peer.mType = static_cast(PeerType::OUTBOUND); @@ -305,6 +296,14 @@ PeerManager::update(PeerRecord& peer, TypeUpdate type) } break; } + case TypeUpdate::UPDATE_TO_OUTBOUND: + { + if (peer.mType == static_cast(PeerType::INBOUND)) + { + peer.mType = static_cast(PeerType::OUTBOUND); + } + break; + } default: { abort(); @@ -333,10 +332,6 @@ PeerManager::update(PeerRecord& peer, BackOffUpdate backOff, Application& app) { switch (backOff) { - case BackOffUpdate::KEEP: - { - break; - } case BackOffUpdate::HARD_RESET: { peer.mNumFailures = 0; diff --git a/src/overlay/PeerManager.h b/src/overlay/PeerManager.h index fd7797c090..a4fbab0dc4 100644 --- a/src/overlay/PeerManager.h +++ b/src/overlay/PeerManager.h @@ -64,16 +64,14 @@ class PeerManager public: enum class TypeUpdate { - KEEP, - SET_INBOUND, SET_OUTBOUND, SET_PREFERRED, - REMOVE_PREFERRED + REMOVE_PREFERRED, + UPDATE_TO_OUTBOUND }; enum class BackOffUpdate { - KEEP, HARD_RESET, RESET, INCREASE