@@ -29,12 +29,18 @@ import qualified Ouroboros.Network.Protocol.PeerSharing.Type as PS
2929import Ouroboros.Network.SizeInBytes (SizeInBytes (.. ))
3030
3131import Control.Monad.Class.MonadTime.SI (Time (.. ))
32- import Data.Aeson (ToJSON (.. ), Value (String ), (.=) )
32+ import Data.Aeson (ToJSON (.. ), Value (Array , Number , String ), (.=) )
3333import Data.Proxy (Proxy (.. ))
3434import Data.Time (DiffTime )
3535import Data.Text (pack )
3636import Network.TypedProtocol.Codec (AnyMessage (AnyMessageAndAgency ))
3737
38+ import qualified Data.Bits as Bits
39+ import qualified Data.Vector as V
40+ import LeiosDemoTypes (EbHash (.. ), LeiosEb , LeiosPoint (.. ), LeiosTx , leiosEbBytesSize , leiosTxBytesSize , prettyBitmap , prettyEbHash )
41+ import qualified LeiosDemoOnlyTestFetch as LF
42+ import qualified LeiosDemoOnlyTestNotify as LN
43+
3844--------------------------------------------------------------------------------
3945-- BlockFetch Tracer
4046--------------------------------------------------------------------------------
@@ -466,3 +472,122 @@ instance MetaTrace (TraceKeepAliveClient remotePeer) where
466472 documentFor _ = Just " "
467473
468474 allNamespaces = [Namespace [] [" KeepAliveClient" ]]
475+
476+ -----
477+
478+ instance ToJSON EbHash where toJSON = toJSON . prettyEbHash
479+
480+ instance LogFormatting (AnyMessage (LN. LeiosNotify LeiosPoint () )) where
481+ forHuman = showT
482+
483+ forMachine _dtal (AnyMessageAndAgency _stok msg) = case msg of
484+
485+ LN. MsgLeiosNotificationRequestNext ->
486+ mconcat [ " kind" .= String " MsgLeiosNotificationRequestNext"
487+ ]
488+
489+ LN. MsgLeiosBlockAnnouncement () ->
490+ mconcat [ " kind" .= String " MsgLeiosBlockAnnouncement"
491+ ]
492+ LN. MsgLeiosBlockOffer (MkLeiosPoint ebSlot ebHash) ebBytesSize ->
493+ mconcat [ " kind" .= String " MsgLeiosBlockOffer"
494+ , " ebSlot" .= ebSlot
495+ , " ebHash" .= ebHash
496+ , " ebBytesSize" .= ebBytesSize
497+ ]
498+ LN. MsgLeiosBlockTxsOffer (MkLeiosPoint ebSlot ebHash) ->
499+ mconcat [ " kind" .= String " MsgLeiosBlockTxsOffer"
500+ , " ebSlot" .= ebSlot
501+ , " ebHash" .= ebHash
502+ ]
503+
504+ LN. MsgDone ->
505+ mconcat [ " kind" .= String " MsgDone"
506+ ]
507+
508+ instance LogFormatting (AnyMessage (LF. LeiosFetch LeiosPoint LeiosEb LeiosTx )) where
509+ forHuman = showT
510+
511+ forMachine _dtal (AnyMessageAndAgency _stok msg) = case msg of
512+
513+ LF. MsgLeiosBlockRequest (MkLeiosPoint ebSlot ebHash) ->
514+ mconcat [ " kind" .= String " MsgLeiosBlockRequest"
515+ , " ebSlot" .= ebSlot
516+ , " ebHash" .= ebHash
517+ ]
518+
519+ LF. MsgLeiosBlock eb ->
520+ mconcat [ " kind" .= String " MsgLeiosBlock"
521+ , " eb" .= String " <elided>"
522+ , " ebBytesSize" .= Number (fromIntegral $ leiosEbBytesSize eb)
523+ ]
524+
525+ LF. MsgLeiosBlockTxsRequest (MkLeiosPoint ebSlot ebHash) bitmaps ->
526+ mconcat [ " kind" .= String " MsgLeiosBlockTxsRequest"
527+ , " ebSlot" .= ebSlot
528+ , " ebHash" .= ebHash
529+ , " numTxs" .= Number (fromIntegral $ sum $ map (Bits. popCount . snd ) bitmaps)
530+ , " bitmaps" .= Array (V. fromList $ map (String . pack . prettyBitmap) bitmaps)
531+ ]
532+
533+ LF. MsgLeiosBlockTxs txs ->
534+ mconcat [ " kind" .= String " MsgLeiosBlockTxs"
535+ , " numTxs" .= Number (fromIntegral (V. length txs))
536+ , " txsBytesSize" .= Number (fromIntegral $ V. sum $ V. map leiosTxBytesSize txs)
537+ , " txs" .= String " <elided>"
538+ ]
539+
540+ -- LF.MsgLeiosVotesRequest
541+ -- LF.MsgLeiosVoteDelivery
542+
543+ -- LF.MsgLeiosBlockRangeRequest
544+ -- LF.MsgLeiosNextBlockAndTxsInRange
545+ -- LF.MsgLeiosLastBlockAndTxsInRange
546+
547+ LF. MsgDone ->
548+ mconcat [ " kind" .= String " MsgDone"
549+ ]
550+
551+ where
552+ -- agency :: Aeson.Object
553+ -- agency = "agency" .= show stok
554+
555+ instance MetaTrace (AnyMessage (LN. LeiosNotify LeiosPoint () )) where
556+ namespaceFor (AnyMessageAndAgency _stok msg) = case msg of
557+ LN. MsgLeiosNotificationRequestNext {} -> Namespace [] [" RequestNext" ]
558+ LN. MsgLeiosBlockAnnouncement {} -> Namespace [] [" BlockAnnouncement" ]
559+ LN. MsgLeiosBlockOffer {} -> Namespace [] [" BlockOffer" ]
560+ LN. MsgLeiosBlockTxsOffer {} -> Namespace [] [" BlockTxsOffer" ]
561+ LN. MsgDone -> Namespace [] [" Done" ]
562+
563+ severityFor _ _ = Just Debug
564+
565+ documentFor _ = Nothing
566+
567+ allNamespaces = [
568+ Namespace [] [" RequestNext" ]
569+ , Namespace [] [" BlockAnnouncement" ]
570+ , Namespace [] [" BlockOffer" ]
571+ , Namespace [] [" BlockTxsOffer" ]
572+ , Namespace [] [" Done" ]
573+ ]
574+
575+ instance MetaTrace (AnyMessage (LF. LeiosFetch LeiosPoint LeiosEb LeiosTx )) where
576+ namespaceFor (AnyMessageAndAgency _stok msg) = case msg of
577+ LF. MsgLeiosBlockRequest {} -> Namespace [] [" BlockRequest" ]
578+ LF. MsgLeiosBlock {} -> Namespace [] [" Block" ]
579+ LF. MsgLeiosBlockTxsRequest {} -> Namespace [] [" BlockTxsRequest" ]
580+ LF. MsgLeiosBlockTxs {} -> Namespace [] [" BlockTxs" ]
581+ LF. MsgDone -> Namespace [] [" Done" ]
582+
583+ severityFor _ _ = Just Debug
584+
585+ documentFor _ = Nothing
586+
587+ allNamespaces = [
588+ Namespace [] [" BlockRequest" ]
589+ , Namespace [] [" Block" ]
590+ , Namespace [] [" BlockTxsRequest" ]
591+ , Namespace [] [" BlockTxs" ]
592+ , Namespace [] [" Done" ]
593+ ]
0 commit comments