Skip to content

Commit

Permalink
Merge pull request libbitcoin#417 from evoskuil/master
Browse files Browse the repository at this point in the history
Config types must use non pmr vectors.
  • Loading branch information
evoskuil authored Jul 7, 2024
2 parents 529e043 + ed7eb1d commit 81bf96c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/bitcoin/network/config/address.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class BCT_API address
messages::address_item::cptr address_;
};

typedef std_vector<address> addresses;
typedef std::vector<address> addresses;

} // namespace config
} // namespace network
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/network/config/authority.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class BCT_API authority
uint8_t cidr_;
};

typedef std_vector<authority> authorities;
typedef std::vector<authority> authorities;

} // namespace config
} // namespace network
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/network/config/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class BCT_API endpoint
uint16_t port_;
};

typedef std_vector<endpoint> endpoints;
typedef std::vector<endpoint> endpoints;

} // namespace config
} // namespace network
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/network/messages/compact_block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct BCT_API compact_block
{
typedef std::shared_ptr<const compact_block> cptr;
typedef system::mini_hash short_id;
typedef system::mini_hashes short_id_list;
typedef std_vector<short_id> short_id_list;

static const identifier id;
static const std::string command;
Expand Down
15 changes: 6 additions & 9 deletions src/messages/headers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ bool headers::is_sequential() const NOEXCEPT

hashes headers::to_hashes() const NOEXCEPT
{
hashes out;
hashes out{};
out.reserve(header_ptrs.size());

for (const auto& header: header_ptrs)
Expand All @@ -144,18 +144,15 @@ hashes headers::to_hashes() const NOEXCEPT

inventory_items headers::to_inventory(inventory::type_id type) const NOEXCEPT
{
inventory_items out;
inventory_items out{};
out.reserve(header_ptrs.size());

for (const auto& header: header_ptrs)
{
#if defined(HAVE_CLANG)
// emplace_back aggregate initialization requires clang 16.
out.push_back({ type, header->hash() });
#else
out.emplace_back(type, header->hash());
#endif
}

// emplace_back aggregate initialization requires clang 16.
// This also fails following change to pmr vector.
////out.emplace_back(type, header->hash());

return out;
}
Expand Down
16 changes: 14 additions & 2 deletions test/test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,22 @@ namespace std {
std::ostream& operator<<(std::ostream& stream,
const system::data_slice& slice) noexcept;

// vector<Type> -> join(<<Type)
// std::vector<Type> -> join(<<Type)
template <typename Type>
std::ostream& operator<<(std::ostream& stream,
const std_vector<Type>& values) noexcept
const std::vector<Type>& values) NOEXCEPT
{
// Ok when testing serialize because only used for error message out.
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
stream << system::serialize(values);
BC_POP_WARNING()
return stream;
}

// std_vector<Type> -> join(<<Type)
template <typename Type>
std::ostream& operator<<(std::ostream& stream,
const std_vector<Type>& values) NOEXCEPT
{
// Ok when testing serialize because only used for error message out.
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
Expand Down

0 comments on commit 81bf96c

Please sign in to comment.