6 #include <fmt/format.h> 7 #include <libp2p/peer/peer_id.hpp> 10 #ifndef KAGOME__FMT_FORMATTER_PEERID 11 #define KAGOME__FMT_FORMATTER_PEERID 13 #include <fmt/format.h> 14 #include <libp2p/peer/peer_id.hpp> 19 char presentation =
's';
22 constexpr
auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) {
24 auto it = ctx.begin(), end = ctx.end();
25 if (it != end && (*it ==
's' || *it ==
'l')) {
30 if (it != end && *it !=
'}') {
31 throw format_error(
"invalid format");
40 template <
typename FormatContext>
42 -> decltype(ctx.out()) {
45 auto &&b58 = peer_id.toBase58();
47 if (presentation ==
's') {
48 return format_to(ctx.out(),
50 std::string_view(b58.data() + b58.size()
51 - std::min<size_t>(6, b58.size()),
52 std::min<size_t>(6, b58.size())));
55 return format_to(ctx.out(),
"{}", b58);
59 #endif // KAGOME__FMT_FORMATTER_PEERID
libp2p::peer::PeerId PeerId