1818 */
1919#include < bitcoin/node/protocols/protocol_explore.hpp>
2020
21+ #include < algorithm>
2122#include < optional>
23+ #include < ranges>
2224#include < utility>
2325#include < bitcoin/node/define.hpp>
2426#include < bitcoin/node/parse/parse.hpp>
@@ -36,6 +38,7 @@ using namespace network::rpc;
3638using namespace network ::http;
3739using namespace network ::messages::peer;
3840using namespace std ::placeholders;
41+ using namespace boost ::json;
3942
4043// Avoiding namespace conflict.
4144using object_type = network::rpc::object_t ;
@@ -179,24 +182,27 @@ bool protocol_explore::handle_get_block_txs(const code& ec,
179182 if (stopped (ec))
180183 return false ;
181184
182- // TODO: iterate, naturally sorted by position.
183185 const auto & query = archive ();
184186 if (const auto hashes = query.get_tx_keys (to_header (height, hash));
185187 !hashes.empty ())
186188 {
189+ const auto size = hashes.size () * hash_size;
190+
187191 switch (media)
188192 {
189193 case data:
190194 case text:
191195 {
192- const auto size = hashes.size () * hash_size;
193196 const auto data = pointer_cast<const uint8_t >(hashes.data ());
194197 send_wire (media, { data, std::next (data, size) });
195198 return true ;
196199 }
197200 case json:
198201 {
199- // TODO: json array of base16 hashes.
202+ array out (hashes.size ());
203+ std::ranges::transform (hashes, out.begin (),
204+ [](const auto & hash) { return encode_base16 (hash); });
205+ send_json ({}, out, size);
200206 return true ;
201207 }
202208 }
0 commit comments