From eceeda1eec37bfbe97f3691a9bd38f1157130298 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 10 Jan 2012 01:20:22 +0100 Subject: [PATCH] Catch p2p exceptions --- bitcoin.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/bitcoin.cpp b/bitcoin.cpp index 61b9847..967e905 100644 --- a/bitcoin.cpp +++ b/bitcoin.cpp @@ -259,16 +259,21 @@ public: }; bool TestNode(const CIPPort &cip, int &ban, int &clientV, vector& vAddr) { - CNode node(cip, vAddr); - bool ret = node.Run(); - if (!ret) { - ban = node.GetBan(); - } else { - ban = 0; - } - clientV = node.GetClientVersion(); + try { + CNode node(cip, vAddr); + bool ret = node.Run(); + if (!ret) { + ban = node.GetBan(); + } else { + ban = 0; + } + clientV = node.GetClientVersion(); // printf("%s: %s!!!\n", cip.ToString().c_str(), ret ? "GOOD" : "BAD"); - return ret; + return ret; + } catch(std::ios_base::failure& e) { + ban = 0; + return false; + } } /*