Show the routing key prefix on each contact
Contacts now show the first path-hash-width bytes of their public key as a monospace badge before the path label, so they can be matched to hops in routing paths and told apart. The width follows the radio's path hash size setting.
This commit is contained in:
1 parent
4c9705b3cb
commit
c296597a2d
24 files changed
+253
-2
No files matched your search
@@ -43,6 +43,17 @@ class Contact {
|
||||
|
||||
String get publicKeyHex => pubKeyToHex(publicKey);
|
||||
|
||||
/// Uppercase hex of the first [byteWidth] public-key bytes: the hash this
|
||||
/// node appears as in routing paths.
|
||||
String publicKeyPrefixHex(int byteWidth) {
|
||||
final width = byteWidth.clamp(1, 3).toInt();
|
||||
return publicKey
|
||||
.take(width)
|
||||
.map((b) => b.toRadixString(16).padLeft(2, '0'))
|
||||
.join()
|
||||
.toUpperCase();
|
||||
}
|
||||
|
||||
/// Non-localized type label, intended for logs and non-UI exports
|
||||
/// (e.g. GPX). For UI use the `typeLabel(l10n)` extension in
|
||||
/// `lib/l10n/contact_localization.dart`.
|
||||
|
||||
Reference in new issue
Block a user