summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Identity.hs9
-rw-r--r--src/Main.hs4
2 files changed, 11 insertions, 2 deletions
diff --git a/src/Identity.hs b/src/Identity.hs
index ff63353..96346d8 100644
--- a/src/Identity.hs
+++ b/src/Identity.hs
@@ -2,9 +2,12 @@ module Identity (
Identity, IdentityData(..),
emptyIdentity,
finalOwner,
+ displayIdentity,
) where
+import Data.Maybe
import Data.Text (Text)
+import qualified Data.Text as T
import PubKey
import Storage
@@ -51,3 +54,9 @@ unfoldOwners cur = cur : case idOwner $ fromStored $ signedData $ fromStored cur
finalOwner :: Stored Identity -> Stored Identity
finalOwner = last . unfoldOwners
+
+displayIdentity :: Stored Identity -> Text
+displayIdentity sidentity = T.concat
+ [ T.intercalate (T.pack " / ") $ map (fromMaybe (T.pack "<unnamed>") . idName . fromStored . signedData . fromStored) owners
+ ]
+ where owners = reverse $ unfoldOwners sidentity
diff --git a/src/Main.hs b/src/Main.hs
index 35f5a23..e6e9d9c 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -77,14 +77,14 @@ main = do
erebosHead <- loadErebosHead st
let serebos = wrappedLoad (headRef erebosHead) :: Stored Erebos
self = erbIdentity $ fromStored serebos
- print $ fromStored self
+ T.putStrLn $ displayIdentity self
(chanPeer, chanSvc) <- startServer bhost $ erbIdentity $ fromStored serebos
void $ forkIO $ void $ forever $ do
peer@Peer { peerAddress = DatagramAddress addr } <- readChan chanPeer
print addr
- putStrLn $ maybe "<noid>" show $ peerIdentity peer
+ T.putStrLn $ maybe (T.pack "<noid>") displayIdentity $ peerIdentity peer
if | Just powner <- finalOwner <$> peerIdentity peer
, _:_ <- peerChannels peer
-> do