Skip to content

Commit 690dfe7

Browse files
committed
Fix up spenders and address explore queries.
1 parent c3a598a commit 690dfe7

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

src/protocols/protocol_explore.cpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -879,12 +879,14 @@ bool protocol_explore::handle_get_output_spenders(const code& ec,
879879
return true;
880880
}
881881

882-
const auto size = points.size() * chain::point::serialized_size();
882+
// TODO: dedup and lexical sort.
883883
chain::points out(points.size());
884-
std::ranges::transform(points, out.begin(),
885-
[&](const auto& link) NOEXCEPT { return query.get_point(link); });
884+
std::ranges::transform(points, out.begin(), [&](const auto& link) NOEXCEPT
885+
{
886+
return query.get_spender(link);
887+
});
886888

887-
// TODO: dedup and sort by height/position/index in query.
889+
const auto size = out.size() * chain::point::serialized_size();
888890
switch (media)
889891
{
890892
case data:
@@ -928,21 +930,25 @@ bool protocol_explore::handle_get_address(const code& ec, interface::address,
928930
return true;
929931
}
930932

931-
// TODO: dedup and sort by height/position/index in query.
932-
if (const auto ptr = query.get_output(outputs.front()))
933+
// TODO: dedup and lexical sort.
934+
chain::points out(outputs.size());
935+
std::ranges::transform(outputs, out.begin(), [&](const auto& link) NOEXCEPT
933936
{
934-
switch (media)
935-
{
936-
case data:
937-
send_chunk({});
938-
return true;
939-
case text:
940-
send_text(encode_base16({}));
941-
return true;
942-
case json:
943-
send_json(value_from(*ptr), {});
944-
return true;
945-
}
937+
return query.get_spent(link);
938+
});
939+
940+
const auto size = out.size() * chain::point::serialized_size();
941+
switch (media)
942+
{
943+
case data:
944+
send_chunk(to_bin_array(out, size));
945+
return true;
946+
case text:
947+
send_text(to_hex_array(out, size));
948+
return true;
949+
case json:
950+
send_json(value_from(out), two * size);
951+
return true;
946952
}
947953

948954
send_not_found();

0 commit comments

Comments
 (0)