Skip to content

Commit 388cb90

Browse files
authored
Merge pull request #619 from evoskuil/master
Remove dead code, comments.
2 parents 803b7ef + 9f2665c commit 388cb90

File tree

5 files changed

+24
-313
lines changed

5 files changed

+24
-313
lines changed

include/bitcoin/network/beast.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ using file_request_cptr = std::shared_ptr<const file_request>;
7272
using file_response_ptr = std::shared_ptr<file_response>;
7373
using file_request_ptr = std::shared_ptr<file_request>;
7474

75-
/// HACK: must cast writer to non-const.
7675
/// beast::http::span_body<uint8_t>
76+
/// Must cast write span uint8_t* to non-const.
7777
using span_body = boost::beast::http::span_body<uint8_t>;
7878
using span_request = boost::beast::http::request<span_body>;
7979
using span_response = boost::beast::http::response<span_body>;
@@ -85,6 +85,7 @@ using span_response_ptr = std::shared_ptr<span_response>;
8585
using span_request_ptr = std::shared_ptr<span_request>;
8686

8787
/// beast::http::buffer_body
88+
/// Must cast write buffer void* to non-const.
8889
using buffer_body = boost::beast::http::buffer_body;
8990
using buffer_request = boost::beast::http::request<buffer_body>;
9091
using buffer_response = boost::beast::http::response<buffer_body>;

include/bitcoin/network/net/proxy.hpp

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -112,44 +112,17 @@ class BCT_API proxy
112112
virtual void write(const asio::const_buffer& payload,
113113
count_handler&& handler) NOEXCEPT;
114114

115-
/// HTTP Readers.
115+
/// HTTP.
116116
/// -----------------------------------------------------------------------
117117

118118
/// Read full http variant request from the socket, using provided buffer.
119119
virtual void read(http::flat_buffer& buffer, http::request& request,
120120
count_handler&& handler) NOEXCEPT;
121121

122-
/// Read full http string request from the socket, using provided buffer.
123-
virtual void read(http::flat_buffer& buffer, http::string_request& request,
124-
count_handler&& handler) NOEXCEPT;
125-
126-
/// Read full http json request from the socket, using provided buffer.
127-
virtual void read(http::flat_buffer& buffer, http::json_request& request,
128-
count_handler&& handler) NOEXCEPT;
129-
130-
/// HTTP Writers.
131-
/// -----------------------------------------------------------------------
132-
133122
/// Write full http variant response to the socket (json buffer in body).
134123
virtual void write(http::response& response,
135124
count_handler&& handler) NOEXCEPT;
136125

137-
/// Write full http string response to the socket.
138-
virtual void write(http::string_response& response,
139-
count_handler&& handler) NOEXCEPT;
140-
141-
/// Write full http json response to the socket (serialize buffer in body).
142-
virtual void write(http::json_response& response,
143-
count_handler&& handler) NOEXCEPT;
144-
145-
/// Write full http data response to the socket.
146-
virtual void write(http::data_response& response,
147-
count_handler&& handler) NOEXCEPT;
148-
149-
/// Write full http file response to the socket.
150-
virtual void write(http::file_response& response,
151-
count_handler&& handler) NOEXCEPT;
152-
153126
private:
154127
typedef std::deque<std::pair<asio::const_buffer, count_handler>> queue;
155128

include/bitcoin/network/net/socket.hpp

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class BCT_API socket
6464
/// Block on threadpool.join() to ensure termination of the connection.
6565
virtual void stop() NOEXCEPT;
6666

67-
/// TCP.
67+
/// Accept/Connect.
6868
/// -----------------------------------------------------------------------
6969

7070
/// Accept an incoming connection, handler posted to *acceptor* strand.
@@ -76,6 +76,9 @@ class BCT_API socket
7676
virtual void connect(const asio::endpoints& range,
7777
result_handler&& handler) NOEXCEPT;
7878

79+
/// TCP.
80+
/// -----------------------------------------------------------------------
81+
7982
/// Read full buffer from the socket, handler posted to socket strand.
8083
virtual void read(const asio::mutable_buffer& out,
8184
count_handler&& handler) NOEXCEPT;
@@ -84,44 +87,17 @@ class BCT_API socket
8487
virtual void write(const asio::const_buffer& in,
8588
count_handler&& handler) NOEXCEPT;
8689

87-
/// HTTP Readers.
90+
/// HTTP.
8891
/// -----------------------------------------------------------------------
8992

9093
/// Read full http variant request from the socket.
9194
virtual void http_read(http::flat_buffer& buffer,
9295
http::request& request, count_handler&& handler) NOEXCEPT;
9396

94-
/// Read full http string request from the socket.
95-
virtual void http_read(http::flat_buffer& buffer,
96-
http::string_request& request, count_handler&& handler) NOEXCEPT;
97-
98-
/// Read full http json request from the socket.
99-
virtual void http_read(http::flat_buffer& buffer,
100-
http::json_request& request, count_handler&& handler) NOEXCEPT;
101-
102-
/// HTTP Writers.
103-
/// -----------------------------------------------------------------------
104-
10597
/// Write full http variant response to the socket.
10698
virtual void http_write(http::response& response,
10799
count_handler&& handler) NOEXCEPT;
108100

109-
/// Write full http string response to the socket.
110-
virtual void http_write(http::string_response& response,
111-
count_handler&& handler) NOEXCEPT;
112-
113-
/// Write full http json response to the socket.
114-
virtual void http_write(http::json_response& response,
115-
count_handler&& handler) NOEXCEPT;
116-
117-
/// Write full http data response to the socket.
118-
virtual void http_write(http::data_response& response,
119-
count_handler&& handler) NOEXCEPT;
120-
121-
/// Write full http file response to the socket.
122-
virtual void http_write(http::file_response& response,
123-
count_handler&& handler) NOEXCEPT;
124-
125101
/// Properties.
126102
/// -----------------------------------------------------------------------
127103

@@ -153,44 +129,24 @@ class BCT_API socket
153129
private:
154130
void do_stop() NOEXCEPT;
155131

156-
// tcp
132+
// accept/connect
157133
void do_connect(const asio::endpoints& range,
158134
const result_handler& handler) NOEXCEPT;
135+
136+
// tcp
159137
void do_read(const asio::mutable_buffer& out,
160138
const count_handler& handler) NOEXCEPT;
161139
void do_write(const asio::const_buffer& in,
162140
const count_handler& handler) NOEXCEPT;
163141

164-
// http readers
142+
// http
165143
void do_http_read(
166144
const std::reference_wrapper<http::flat_buffer>& buffer,
167145
const std::reference_wrapper<http::request>& request,
168146
const count_handler& handler) NOEXCEPT;
169-
void do_http_read_string(
170-
const std::reference_wrapper<http::flat_buffer>& buffer,
171-
const std::reference_wrapper<http::string_request>& request,
172-
const count_handler& handler) NOEXCEPT;
173-
void do_http_read_json(
174-
const std::reference_wrapper<http::flat_buffer>& buffer,
175-
const std::reference_wrapper<http::json_request>& request,
176-
const count_handler& handler) NOEXCEPT;
177-
178-
// http writers
179147
void do_http_write(
180148
const std::reference_wrapper<http::response>& response,
181149
const count_handler& handler) NOEXCEPT;
182-
void do_http_write_string(
183-
const std::reference_wrapper<http::string_response>& response,
184-
const count_handler& handler) NOEXCEPT;;
185-
void do_http_write_json(
186-
const std::reference_wrapper<http::json_response>& response,
187-
const count_handler& handler) NOEXCEPT;
188-
void do_http_write_data(
189-
const std::reference_wrapper<http::data_response>& response,
190-
const count_handler& handler) NOEXCEPT;
191-
void do_http_write_file(
192-
const std::reference_wrapper<http::file_response>& response,
193-
const count_handler& handler) NOEXCEPT;
194150

195151
// completion
196152
void handle_accept(const boost_code& ec,

src/net/proxy.cpp

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ void proxy::write(const asio::const_buffer& payload,
170170
shared_from_this(), payload, std::move(handler)));
171171
}
172172

173-
// HTTP Readers.
173+
// HTTP.
174174
// ----------------------------------------------------------------------------
175-
// Method waiting() is invoked directly if read() is called from strand().
176175

176+
// Method waiting() is invoked directly if read() is called from strand().
177177
void proxy::read(http::flat_buffer& buffer, http::request& request,
178178
count_handler&& handler) NOEXCEPT
179179
{
@@ -183,58 +183,13 @@ void proxy::read(http::flat_buffer& buffer, http::request& request,
183183
socket_->http_read(buffer, request, std::move(handler));
184184
}
185185

186-
void proxy::read(http::flat_buffer& buffer, http::string_request& request,
187-
count_handler&& handler) NOEXCEPT
188-
{
189-
boost::asio::dispatch(strand(),
190-
std::bind(&proxy::waiting, shared_from_this()));
191-
192-
socket_->http_read(buffer, request, std::move(handler));
193-
}
194-
195-
void proxy::read(http::flat_buffer& buffer, http::json_request& request,
196-
count_handler&& handler) NOEXCEPT
197-
{
198-
boost::asio::dispatch(strand(),
199-
std::bind(&proxy::waiting, shared_from_this()));
200-
201-
socket_->http_read(buffer, request, std::move(handler));
202-
}
203-
204-
// HTTP Writers.
205-
// ----------------------------------------------------------------------------
206186
// Writes are composed but http is half duplex so there is no interleave risk.
207-
208187
void proxy::write(http::response& response,
209188
count_handler&& handler) NOEXCEPT
210189
{
211190
socket_->http_write(response, std::move(handler));
212191
}
213192

214-
void proxy::write(http::string_response& response,
215-
count_handler&& handler) NOEXCEPT
216-
{
217-
socket_->http_write(response, std::move(handler));
218-
}
219-
220-
void proxy::write(http::json_response& response,
221-
count_handler&& handler) NOEXCEPT
222-
{
223-
socket_->http_write(response, std::move(handler));
224-
}
225-
226-
void proxy::write(http::data_response& response,
227-
count_handler&& handler) NOEXCEPT
228-
{
229-
socket_->http_write(response, std::move(handler));
230-
}
231-
232-
void proxy::write(http::file_response& response,
233-
count_handler&& handler) NOEXCEPT
234-
{
235-
socket_->http_write(response, std::move(handler));
236-
}
237-
238193
// Send cycle (send continues until queue is empty).
239194
// ----------------------------------------------------------------------------
240195
// stackoverflow.com/questions/7754695/boost-asio-async-write-how-to-not-

0 commit comments

Comments
 (0)