diff options
Diffstat (limited to 'src/i2p.cpp')
-rw-r--r-- | src/i2p.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/i2p.cpp b/src/i2p.cpp index ccba14d63d..c45bcc15d2 100644 --- a/src/i2p.cpp +++ b/src/i2p.cpp @@ -3,7 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <chainparams.h> -#include <compat.h> +#include <compat/compat.h> #include <compat/endian.h> #include <crypto/sha256.h> #include <fs.h> @@ -69,12 +69,11 @@ static std::string SwapBase64(const std::string& from) static Binary DecodeI2PBase64(const std::string& i2p_b64) { const std::string& std_b64 = SwapBase64(i2p_b64); - bool invalid; - Binary decoded = DecodeBase64(std_b64.c_str(), &invalid); - if (invalid) { + auto decoded = DecodeBase64(std_b64); + if (!decoded) { throw std::runtime_error(strprintf("Cannot decode Base64: \"%s\"", i2p_b64)); } - return decoded; + return std::move(*decoded); } /** @@ -151,8 +150,8 @@ bool Session::Accept(Connection& conn) throw std::runtime_error("wait on socket failed"); } - if ((occurred & Sock::RECV) == 0) { - // Timeout, no incoming connections within MAX_WAIT_FOR_IO. + if (occurred == 0) { + // Timeout, no incoming connections or errors within MAX_WAIT_FOR_IO. continue; } @@ -243,7 +242,7 @@ std::string Session::Reply::Get(const std::string& key) const template <typename... Args> void Session::Log(const std::string& fmt, const Args&... args) const { - LogPrint(BCLog::I2P, "I2P: %s\n", tfm::format(fmt, args...)); + LogPrint(BCLog::I2P, "%s\n", tfm::format(fmt, args...)); } Session::Reply Session::SendRequestAndGetReply(const Sock& sock, @@ -377,8 +376,8 @@ void Session::CreateIfNotCreatedAlready() m_session_id = session_id; m_control_sock = std::move(sock); - LogPrintf("I2P: SAM session created: session id=%s, my address=%s\n", m_session_id, - m_my_addr.ToString()); + LogPrintfCategory(BCLog::I2P, "SAM session created: session id=%s, my address=%s\n", + m_session_id, m_my_addr.ToString()); } std::unique_ptr<Sock> Session::StreamAccept() @@ -411,7 +410,7 @@ void Session::Disconnect() Log("Destroying session %s", m_session_id); } } - m_control_sock->Reset(); + m_control_sock = std::make_unique<Sock>(INVALID_SOCKET); m_session_id.clear(); } } // namespace sam |