Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: iceseer <[email protected]>
  • Loading branch information
iceseer committed Dec 13, 2024
1 parent 4284171 commit e535e58
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/authority_discovery/query/authority_peer_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace kagome::authority_discovery {

common::Buffer raw{};
std::optional<TimestampScale> time{};
scale::PeerInfoSerializable peer{};
::scale::PeerInfoSerializable peer{};
};

} // namespace kagome::authority_discovery
4 changes: 2 additions & 2 deletions core/authority_discovery/timestamp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
#include "scale/big_fixed_integers.hpp"

namespace kagome::authority_discovery {
using Timestamp = scale::uint128_t;
using TimestampScale = scale::Fixed<Timestamp>;
using Timestamp = ::scale::uint128_t;
using TimestampScale = ::scale::Fixed<Timestamp>;
} // namespace kagome::authority_discovery
24 changes: 24 additions & 0 deletions core/scale/kagome_scale.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ namespace kagome::scale {
constexpr void encode(const F &func,
const authority_discovery::AuthorityPeerInfo &c);

constexpr void encode(const Invocable auto &func,
const scale::PeerInfoSerializable &c);

template <typename T>
constexpr void encode(const Invocable auto &func, const Fixed<T> &c);
} // namespace kagome::scale

#include "scale/encoder/primitives.hpp"
Expand Down Expand Up @@ -297,6 +302,25 @@ namespace kagome::scale {
encode(func, c.peer);
}

constexpr void encode(const Invocable auto &func,
const scale::PeerInfoSerializable &c) {
std::vector<std::string> addresses;
addresses.reserve(c.addresses.size());
for (const auto &addr : c.addresses) {
addresses.emplace_back(addr.getStringAddress());
}
encode(func, c.id.toBase58());
encode(func, addresses);
}

template <typename T>
constexpr void encode(const Invocable auto &func, const Fixed<T> &c) {
constexpr size_t bits = Fixed<T>::kByteSize * 8;
for (size_t i = 0; i < bits; i += 8) {
encode(func, ::scale::convert_to<uint8_t>((*c >> i) & 0xFFu));
}
}

} // namespace kagome::scale

#endif // KAGOME_KAGOME_SCALE_HPP

0 comments on commit e535e58

Please sign in to comment.