Skip to content

Commit d883983

Browse files
committed
Style, comments.
1 parent 615eaec commit d883983

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

include/bitcoin/node/protocols/protocol_bitcoind_rpc.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ class BCN_API protocol_bitcoind_rpc
104104
interface::verify_tx_out_set, const std::string&) NOEXCEPT;
105105

106106
private:
107+
// Send the response.
108+
void send_json(boost::json::value&& model, size_t size_hint) NOEXCEPT;
109+
107110
// Provide the request for serialization, keeping it out of dispatch.
108111
void set_post(const post::cptr& post) NOEXCEPT;
109112
const post& get_post() const NOEXCEPT;
110113

111-
// Send the response.
112-
void send_json(boost::json::value&& model, size_t size_hint) NOEXCEPT;
113-
114114
// This is thread safe.
115115
////const options_t& options_;
116116

src/protocols/protocol_bitcoind_rpc.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,8 @@ void protocol_bitcoind_rpc::handle_receive_post(const code& ec,
121121
return;
122122
}
123123

124-
using json_t = json_body::value_type;
125124
const auto& body = post->body();
126-
if (!body.contains<json_t>())
125+
if (!body.contains<json_body::value_type>())
127126
{
128127
send_not_acceptable(*post);
129128
return;
@@ -132,7 +131,7 @@ void protocol_bitcoind_rpc::handle_receive_post(const code& ec,
132131
request_t request{};
133132
try
134133
{
135-
request = value_to<request_t>(body.get<json_t>().model);
134+
request = value_to<request_t>(body.get<json_body::value_type>().model);
136135
}
137136
catch (const boost::system::system_error& e)
138137
{
@@ -145,7 +144,10 @@ void protocol_bitcoind_rpc::handle_receive_post(const code& ec,
145144
return;
146145
}
147146

147+
// The post is saved off during asynchonous handling and used in send_json
148+
// to formulate response headers, isolating handlers from http semantics.
148149
set_post(post);
150+
149151
if (const auto code = dispatcher_.notify(request))
150152
stop(code);
151153
}
@@ -283,18 +285,6 @@ bool protocol_bitcoind_rpc::handle_verify_tx_out_set(const code& ec,
283285
// private
284286
// ----------------------------------------------------------------------------
285287

286-
void protocol_bitcoind_rpc::set_post(const post::cptr& post) NOEXCEPT
287-
{
288-
BC_ASSERT(post);
289-
post_ = post;
290-
}
291-
292-
const protocol_bitcoind_rpc::post& protocol_bitcoind_rpc::get_post() const NOEXCEPT
293-
{
294-
BC_ASSERT(post_);
295-
return *post_;
296-
}
297-
298288
// TODO: post-process response for json-rpc version.
299289
void protocol_bitcoind_rpc::send_json(boost::json::value&& model,
300290
size_t size_hint) NOEXCEPT
@@ -311,6 +301,18 @@ void protocol_bitcoind_rpc::send_json(boost::json::value&& model,
311301
SEND(std::move(response), handle_complete, _1, error::success);
312302
}
313303

304+
void protocol_bitcoind_rpc::set_post(const post::cptr& post) NOEXCEPT
305+
{
306+
BC_ASSERT(post);
307+
post_ = post;
308+
}
309+
310+
const protocol_bitcoind_rpc::post& protocol_bitcoind_rpc::get_post() const NOEXCEPT
311+
{
312+
BC_ASSERT(post_);
313+
return *post_;
314+
}
315+
314316
BC_POP_WARNING()
315317
BC_POP_WARNING()
316318
BC_POP_WARNING()

0 commit comments

Comments
 (0)