Skip to content

Commit 37bb8f7

Browse files
authored
Merge pull request #473 from evoskuil/master
Add error::seeding_complete, apply to seed protocol stop, move boost error.
2 parents 1eef150 + ab7ee95 commit 37bb8f7

5 files changed

Lines changed: 17 additions & 7 deletions

File tree

include/bitcoin/network/error.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ enum error_t : uint8_t
6262
address_unsupported,
6363
address_insufficient,
6464
seeding_unsuccessful,
65+
seeding_complete,
6566

6667
// file system
6768
file_load,

src/error.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ DEFINE_ERROR_T_MESSAGE_MAP(error)
3838
{ address_unsupported, "advertised services unsupported" },
3939
{ address_insufficient, "advertised services insufficient" },
4040
{ seeding_unsuccessful, "seeding unsuccessful" },
41+
{ seeding_complete, "seeding complete" },
4142

4243
// file system
4344
{ file_load, "failed to load file" },
@@ -141,15 +142,15 @@ code asio_to_error_code(const error::boost_code& ec) NOEXCEPT
141142

142143
// connect-resolve
143144
if (ec == boost_error_t::address_family_not_supported ||
144-
ec == boost_error_t::address_not_available ||
145145
ec == boost_error_t::bad_address ||
146146
ec == boost_error_t::destination_address_required ||
147147
ec == asio_netdb_error_t::host_not_found ||
148148
ec == asio_netdb_error_t::host_not_found_try_again)
149149
return error::resolve_failed;
150150

151151
// connect-connect
152-
if (ec == boost_error_t::not_connected ||
152+
if (ec == boost_error_t::address_not_available ||
153+
ec == boost_error_t::not_connected ||
153154
ec == boost_error_t::connection_refused ||
154155
ec == boost_error_t::broken_pipe ||
155156
ec == boost_error_t::host_unreachable ||

src/net/connector.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ void connector::start(const std::string& hostname, uint16_t port,
119119

120120
// Create a socket and shared finish context.
121121
const auto finish = std::make_shared<bool>(false);
122-
const auto socket = std::make_shared<network::socket>(log, service_,
123-
host);
122+
const auto socket = std::make_shared<network::socket>(log, service_, host);
124123

125124
// Posts handle_timer to strand.
126125
timer_->start(

src/protocols/protocol_seed_209.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void protocol_seed_209::handle_send_get_address(const code& ec) NOEXCEPT
111111
sent_get_address_ = true;
112112

113113
if (complete())
114-
stop(error::success);
114+
stop(error::seeding_complete);
115115
}
116116

117117
address::cptr protocol_seed_209::filter(
@@ -192,7 +192,7 @@ void protocol_seed_209::handle_save_addresses(const code& ec,
192192
received_address_ = !is_one(start_size);
193193

194194
if (complete())
195-
stop(error::success);
195+
stop(error::seeding_complete);
196196
}
197197

198198
// Outbound (fetch and send addresses).
@@ -232,7 +232,7 @@ void protocol_seed_209::handle_send_address(const code& ec) NOEXCEPT
232232
////sent_address_ = true;
233233

234234
if (complete())
235-
stop(error::success);
235+
stop(error::seeding_complete);
236236
}
237237

238238
BC_POP_WARNING()

test/error.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ BOOST_AUTO_TEST_CASE(error_t__code__seeding_unsuccessful__true_exected_message)
9797
BOOST_REQUIRE_EQUAL(ec.message(), "seeding unsuccessful");
9898
}
9999

100+
BOOST_AUTO_TEST_CASE(error_t__code__seeding_complete__true_exected_message)
101+
{
102+
constexpr auto value = error::seeding_complete;
103+
const auto ec = code(value);
104+
BOOST_REQUIRE(ec);
105+
BOOST_REQUIRE(ec == value);
106+
BOOST_REQUIRE_EQUAL(ec.message(), "seeding complete");
107+
}
108+
100109
// file system
101110

102111
BOOST_AUTO_TEST_CASE(error_t__code__file_load__true_exected_message)

0 commit comments

Comments
 (0)