Skip to content

Commit e33a488

Browse files
committed
Use && vs. shared_ptr for || address queries.
1 parent e96a6fc commit e33a488

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

include/bitcoin/node/protocols/protocol_explore.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,8 @@ class BCN_API protocol_explore
151151
const system::hash_cptr& hash) NOEXCEPT;
152152

153153
private:
154-
using outpoints_cptr = std::shared_ptr<outpoint_set>;
155154
using balance_handler = std::function<void(code, uint8_t, uint64_t)>;
156-
using address_handler = std::function<void(code, uint8_t, outpoints_cptr)>;
155+
using address_handler = std::function<void(code, uint8_t, outpoint_set&&)>;
157156

158157
void do_get_address(uint8_t media, const system::hash_cptr& hash,
159158
const address_handler& handler) NOEXCEPT;
@@ -164,7 +163,7 @@ class BCN_API protocol_explore
164163
const address_handler& handler) NOEXCEPT;
165164

166165
void complete_get_address(const code& ec, uint8_t media,
167-
const outpoints_cptr& set) NOEXCEPT;
166+
const outpoint_set& set) NOEXCEPT;
168167

169168
void do_get_address_balance(uint8_t media, const system::hash_cptr& hash,
170169
const balance_handler& handler) NOEXCEPT;

src/protocols/protocol_explore.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ void protocol_explore::do_get_address(uint8_t media, const hash_cptr& hash,
975975
return;
976976
}
977977

978-
const auto set = to_shared<outpoint_set>();
978+
outpoint_set set{};
979979
for (const auto& output: outputs)
980980
{
981981
if (stopping_)
@@ -984,16 +984,16 @@ void protocol_explore::do_get_address(uint8_t media, const hash_cptr& hash,
984984
return;
985985
}
986986

987-
set->insert(query.get_spent(output));
987+
set.insert(query.get_spent(output));
988988
}
989989
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
990990

991-
handler(network::error::success, media, set);
991+
handler(network::error::success, media, std::move(set));
992992
}
993993

994994
// This is shared by the tree get_address.. methods.
995995
void protocol_explore::complete_get_address(const code& ec, uint8_t media,
996-
const outpoints_cptr& set) NOEXCEPT
996+
const outpoint_set& set) NOEXCEPT
997997
{
998998
BC_ASSERT(stranded());
999999

@@ -1007,23 +1007,23 @@ void protocol_explore::complete_get_address(const code& ec, uint8_t media,
10071007
return;
10081008
}
10091009

1010-
if (set->empty())
1010+
if (set.empty())
10111011
{
10121012
send_not_found();
10131013
return;
10141014
}
10151015

1016-
const auto size = set->size() * chain::outpoint::serialized_size();
1016+
const auto size = set.size() * chain::outpoint::serialized_size();
10171017
switch (media)
10181018
{
10191019
case data:
1020-
send_chunk(to_bin_array(*set, size));
1020+
send_chunk(to_bin_array(set, size));
10211021
return;
10221022
case text:
1023-
send_text(to_hex_array(*set, size));
1023+
send_text(to_hex_array(set, size));
10241024
return;
10251025
case json:
1026-
send_json(value_from(*set), two * size);
1026+
send_json(value_from(set), two * size);
10271027
return;
10281028
}
10291029

@@ -1068,7 +1068,7 @@ void protocol_explore::do_get_address_confirmed(uint8_t media,
10681068
return;
10691069
}
10701070

1071-
const auto set = to_shared<outpoint_set>();
1071+
outpoint_set set{};
10721072
for (const auto& output : outputs)
10731073
{
10741074
if (stopping_)
@@ -1077,11 +1077,11 @@ void protocol_explore::do_get_address_confirmed(uint8_t media,
10771077
return;
10781078
}
10791079

1080-
set->insert(query.get_spent(output));
1080+
set.insert(query.get_spent(output));
10811081
}
10821082
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10831083

1084-
handler(network::error::success, media, set);
1084+
handler(network::error::success, media, std::move(set));
10851085
}
10861086

10871087
// handle_get_address_unconfirmed

0 commit comments

Comments
 (0)