{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE QuantifiedConstraints #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

{-# OPTIONS_GHC -Wno-orphans  #-}

module Cardano.Tracing.OrphanInstances.Network () where

import           Cardano.Prelude hiding (group, show)
import           Prelude (String, id, show)

import           Control.Monad.Class.MonadTime (DiffTime, Time (..))
import           Data.Aeson (Value (..))
import qualified Data.Aeson as Aeson
import           Data.Aeson.Types (listValue)
import qualified Data.IP as IP
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import           Data.Text (pack)

import           Network.TypedProtocol.Codec (AnyMessageAndAgency (..))
import           Network.TypedProtocol.Core (PeerHasAgency (..))


import           Network.Mux (MiniProtocolNum (..), MuxTrace (..), WithMuxBearer (..))
import           Network.Socket (SockAddr (..))

import           Cardano.Node.Configuration.TopologyP2P (UseLedger (..))
import           Cardano.Node.Queries (ConvertTxId)
import           Cardano.Tracing.OrphanInstances.Common
import           Cardano.Tracing.Render

import           Ouroboros.Consensus.Block (ConvertRawHash (..), Header, getHeader)
import           Ouroboros.Consensus.Ledger.Query (BlockQuery, Query)
import           Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr, GenTx, GenTxId,
                   HasTxs (..), TxId, txId)
import           Ouroboros.Consensus.Node.Run (RunNode, estimateBlockSize)
import qualified Ouroboros.Network.AnchoredFragment as AF
import qualified Ouroboros.Network.AnchoredSeq as AS
import           Ouroboros.Network.Block
import           Ouroboros.Network.BlockFetch.ClientState (TraceFetchClientState,
                   TraceLabelPeer (..))
import qualified Ouroboros.Network.BlockFetch.ClientState as BlockFetch
import           Ouroboros.Network.BlockFetch.Decision (FetchDecision, FetchDecline (..))
import           Ouroboros.Network.ConnectionHandler (ConnectionHandlerTrace (..))
import           Ouroboros.Network.ConnectionId (ConnectionId (..))
import           Ouroboros.Network.ConnectionManager.Types (AbstractState (..),
                   ConnectionManagerCounters (..), ConnectionManagerTrace (..),
                   OperationResult (..))
import qualified Ouroboros.Network.ConnectionManager.Types as ConnMgr
import           Ouroboros.Network.DeltaQ (GSV (..), PeerGSV (..))
import           Ouroboros.Network.Driver.Limits (ProtocolLimitFailure (..))
import           Ouroboros.Network.InboundGovernor (InboundGovernorTrace (..), RemoteSt (..))
import qualified Ouroboros.Network.InboundGovernor as InboundGovernor
import           Ouroboros.Network.InboundGovernor.State (InboundGovernorCounters (..))
import           Ouroboros.Network.KeepAlive (TraceKeepAliveClient (..))
import           Ouroboros.Network.Magic (NetworkMagic (..))
import           Ouroboros.Network.NodeToClient (NodeToClientVersion, NodeToClientVersionData (..))
import qualified Ouroboros.Network.NodeToClient as NtC
import           Ouroboros.Network.NodeToNode (ErrorPolicyTrace (..), NodeToNodeVersion,
                   NodeToNodeVersionData (..), RemoteAddress, TraceSendRecv (..), WithAddr (..))
import qualified Ouroboros.Network.NodeToNode as NtN
import qualified Ouroboros.Network.PeerSelection.EstablishedPeers as EstablishedPeers
import           Ouroboros.Network.PeerSelection.Governor (DebugPeerSelection (..),
                   PeerSelectionCounters (..), PeerSelectionState (..), PeerSelectionTargets (..),
                   TracePeerSelection (..))
import qualified Ouroboros.Network.PeerSelection.KnownPeers as KnownPeers
import           Ouroboros.Network.PeerSelection.LedgerPeers
import           Ouroboros.Network.PeerSelection.LocalRootPeers (LocalRootPeers)
import qualified Ouroboros.Network.PeerSelection.LocalRootPeers as LocalRootPeers
import           Ouroboros.Network.PeerSelection.PeerStateActions (PeerSelectionActionsTrace (..))
import           Ouroboros.Network.PeerSelection.RootPeersDNS (TraceLocalRootPeers (..),
                   TracePublicRootPeers (..))
import           Ouroboros.Network.PeerSelection.Types (PeerStatus (..))
import           Ouroboros.Network.Protocol.BlockFetch.Type (BlockFetch, Message (..))
import           Ouroboros.Network.Protocol.ChainSync.Type (ChainSync)
import qualified Ouroboros.Network.Protocol.ChainSync.Type as ChainSync
import           Ouroboros.Network.Protocol.Handshake (HandshakeException (..),
                   HandshakeProtocolError (..), RefuseReason (..))
import           Ouroboros.Network.Protocol.LocalStateQuery.Type (LocalStateQuery)
import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as LocalStateQuery
import           Ouroboros.Network.Protocol.LocalTxMonitor.Type (LocalTxMonitor)
import qualified Ouroboros.Network.Protocol.LocalTxMonitor.Type as LocalTxMonitor
import           Ouroboros.Network.Protocol.LocalTxSubmission.Type (LocalTxSubmission)
import qualified Ouroboros.Network.Protocol.LocalTxSubmission.Type as LocalTxSub
import           Ouroboros.Network.Protocol.TxSubmission2.Type as TxSubmission2
import           Ouroboros.Network.RethrowPolicy (ErrorCommand (..))
import           Ouroboros.Network.Server2 (ServerTrace (..))
import qualified Ouroboros.Network.Server2 as Server
import           Ouroboros.Network.Snocket (LocalAddress (..))
import           Ouroboros.Network.Subscription (ConnectResult (..), DnsTrace (..),
                   SubscriberError (..), SubscriptionTrace (..), WithDomainName (..),
                   WithIPList (..))
import           Ouroboros.Network.TxSubmission.Inbound (ProcessedTxCount (..),
                   TraceTxSubmissionInbound (..))
import           Ouroboros.Network.TxSubmission.Outbound (TraceTxSubmissionOutbound (..))

import qualified Ouroboros.Network.Diffusion as ND

{- HLINT ignore "Use record patterns" -}

--
-- * instances of @HasPrivacyAnnotation@ and @HasSeverityAnnotation@
--
-- NOTE: this list is sorted by the unqualified name of the outermost type.

instance HasPrivacyAnnotation (ND.InitializationTracer ntnAddr ntcAddr)
instance HasSeverityAnnotation (ND.InitializationTracer ntnAddr ntcAddr) where
  getSeverityAnnotation :: InitializationTracer ntnAddr ntcAddr -> Severity
getSeverityAnnotation ND.DiffusionErrored {} = Severity
Alert
  getSeverityAnnotation InitializationTracer ntnAddr ntcAddr
_ = Severity
Info

instance HasPrivacyAnnotation (NtC.HandshakeTr LocalAddress NodeToClientVersion)
instance HasSeverityAnnotation (NtC.HandshakeTr LocalAddress NodeToClientVersion) where
  getSeverityAnnotation :: HandshakeTr LocalAddress NodeToClientVersion -> Severity
getSeverityAnnotation HandshakeTr LocalAddress NodeToClientVersion
_ = Severity
Info


instance HasPrivacyAnnotation (NtN.HandshakeTr RemoteAddress NodeToNodeVersion)
instance HasSeverityAnnotation (NtN.HandshakeTr RemoteAddress NodeToNodeVersion) where
  getSeverityAnnotation :: HandshakeTr RemoteAddress NodeToNodeVersion -> Severity
getSeverityAnnotation HandshakeTr RemoteAddress NodeToNodeVersion
_ = Severity
Info


instance HasPrivacyAnnotation NtN.AcceptConnectionsPolicyTrace
instance HasSeverityAnnotation NtN.AcceptConnectionsPolicyTrace where
  getSeverityAnnotation :: AcceptConnectionsPolicyTrace -> Severity
getSeverityAnnotation NtN.ServerTraceAcceptConnectionRateLimiting {} = Severity
Info
  getSeverityAnnotation NtN.ServerTraceAcceptConnectionHardLimit {} = Severity
Warning
  getSeverityAnnotation NtN.ServerTraceAcceptConnectionResume {} = Severity
Info


instance HasPrivacyAnnotation (TraceFetchClientState header)
instance HasSeverityAnnotation (TraceFetchClientState header) where
  getSeverityAnnotation :: TraceFetchClientState header -> Severity
getSeverityAnnotation BlockFetch.AddedFetchRequest {} = Severity
Info
  getSeverityAnnotation BlockFetch.SendFetchRequest {} = Severity
Info
  getSeverityAnnotation BlockFetch.AcknowledgedFetchRequest {} = Severity
Info
  getSeverityAnnotation BlockFetch.StartedFetchBatch {} = Severity
Info
  getSeverityAnnotation BlockFetch.CompletedBlockFetch {} = Severity
Info
  getSeverityAnnotation BlockFetch.CompletedFetchBatch {} = Severity
Info
  getSeverityAnnotation BlockFetch.RejectedFetchBatch {} = Severity
Info
  getSeverityAnnotation BlockFetch.ClientTerminating {} = Severity
Notice


instance HasPrivacyAnnotation (TraceSendRecv a)
instance HasSeverityAnnotation (TraceSendRecv a) where
  getSeverityAnnotation :: TraceSendRecv a -> Severity
getSeverityAnnotation TraceSendRecv a
_ = Severity
Debug


instance HasPrivacyAnnotation a => HasPrivacyAnnotation (TraceLabelPeer peer a)
instance HasSeverityAnnotation a => HasSeverityAnnotation (TraceLabelPeer peer a) where
  getSeverityAnnotation :: TraceLabelPeer peer a -> Severity
getSeverityAnnotation (TraceLabelPeer peer
_p a
a) = a -> Severity
forall a. HasSeverityAnnotation a => a -> Severity
getSeverityAnnotation a
a


instance HasPrivacyAnnotation [TraceLabelPeer peer (FetchDecision [Point header])]
instance HasSeverityAnnotation [TraceLabelPeer peer (FetchDecision [Point header])] where
  getSeverityAnnotation :: [TraceLabelPeer peer (FetchDecision [Point header])] -> Severity
getSeverityAnnotation [] = Severity
Debug
  getSeverityAnnotation [TraceLabelPeer peer (FetchDecision [Point header])]
xs =
      [Severity] -> Severity
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
maximum ([Severity] -> Severity) -> [Severity] -> Severity
forall a b. (a -> b) -> a -> b
$ (TraceLabelPeer peer (FetchDecision [Point header]) -> Severity)
-> [TraceLabelPeer peer (FetchDecision [Point header])]
-> [Severity]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map (\(TraceLabelPeer peer
_ FetchDecision [Point header]
a) -> FetchDecision [Point header] -> Severity
forall a. FetchDecision a -> Severity
fetchDecisionSeverity FetchDecision [Point header]
a) [TraceLabelPeer peer (FetchDecision [Point header])]
xs
    where
      fetchDecisionSeverity :: FetchDecision a -> Severity
      fetchDecisionSeverity :: FetchDecision a -> Severity
fetchDecisionSeverity FetchDecision a
fd =
        case FetchDecision a
fd of
          Left FetchDecline
FetchDeclineChainNotPlausible     -> Severity
Debug
          Left FetchDecline
FetchDeclineChainNoIntersection   -> Severity
Notice
          Left FetchDecline
FetchDeclineAlreadyFetched        -> Severity
Debug
          Left FetchDecline
FetchDeclineInFlightThisPeer      -> Severity
Debug
          Left FetchDecline
FetchDeclineInFlightOtherPeer     -> Severity
Debug
          Left FetchDecline
FetchDeclinePeerShutdown          -> Severity
Info
          Left FetchDecline
FetchDeclinePeerSlow              -> Severity
Info
          Left FetchDeclineReqsInFlightLimit {}  -> Severity
Info
          Left FetchDeclineBytesInFlightLimit {} -> Severity
Info
          Left FetchDeclinePeerBusy {}           -> Severity
Info
          Left FetchDeclineConcurrencyLimit {}   -> Severity
Info
          Right a
_                                -> Severity
Info


instance HasPrivacyAnnotation (TraceTxSubmissionInbound txid tx)
instance HasSeverityAnnotation (TraceTxSubmissionInbound txid tx) where
  getSeverityAnnotation :: TraceTxSubmissionInbound txid tx -> Severity
getSeverityAnnotation TraceTxSubmissionCollected {} = Severity
Debug
  getSeverityAnnotation TraceTxSubmissionProcessed {} = Severity
Debug
  getSeverityAnnotation TraceTxSubmissionInbound txid tx
TraceTxInboundTerminated = Severity
Notice
  getSeverityAnnotation TraceTxInboundCannotRequestMoreTxs {} = Severity
Debug
  getSeverityAnnotation TraceTxInboundCanRequestMoreTxs {} = Severity
Debug


instance HasPrivacyAnnotation (TraceTxSubmissionOutbound txid tx)
instance HasSeverityAnnotation (TraceTxSubmissionOutbound txid tx) where
  getSeverityAnnotation :: TraceTxSubmissionOutbound txid tx -> Severity
getSeverityAnnotation TraceTxSubmissionOutbound txid tx
_ = Severity
Info


instance HasPrivacyAnnotation (TraceKeepAliveClient remotePeer)
instance HasSeverityAnnotation (TraceKeepAliveClient remotePeer) where
  getSeverityAnnotation :: TraceKeepAliveClient remotePeer -> Severity
getSeverityAnnotation TraceKeepAliveClient remotePeer
_ = Severity
Info


instance HasPrivacyAnnotation TraceLedgerPeers
instance HasSeverityAnnotation TraceLedgerPeers where
  getSeverityAnnotation :: TraceLedgerPeers -> Severity
getSeverityAnnotation TraceLedgerPeers
ev =
    case TraceLedgerPeers
ev of
      PickedPeer {}                  -> Severity
Debug
      PickedPeers {}                 -> Severity
Info
      FetchingNewLedgerState {}      -> Severity
Info
      DisabledLedgerPeers {}         -> Severity
Info
      TraceUseLedgerAfter {}         -> Severity
Info
      WaitingOnRequest {}            -> Severity
Debug
      RequestForPeers {}             -> Severity
Debug
      ReusingLedgerState {}          -> Severity
Debug
      FallingBackToBootstrapPeers {} -> Severity
Info


instance HasPrivacyAnnotation (WithAddr addr ErrorPolicyTrace)
instance HasSeverityAnnotation (WithAddr addr ErrorPolicyTrace) where
  getSeverityAnnotation :: WithAddr addr ErrorPolicyTrace -> Severity
getSeverityAnnotation (WithAddr addr
_ ErrorPolicyTrace
ev) = case ErrorPolicyTrace
ev of
    ErrorPolicySuspendPeer {} -> Severity
Warning -- peer misbehaved
    ErrorPolicySuspendConsumer {} -> Severity
Notice -- peer temporarily not useful
    ErrorPolicyLocalNodeError {} -> Severity
Error
    ErrorPolicyResumePeer {} -> Severity
Debug
    ErrorPolicyKeepSuspended {} -> Severity
Debug
    ErrorPolicyResumeConsumer {} -> Severity
Debug
    ErrorPolicyResumeProducer {} -> Severity
Debug
    ErrorPolicyUnhandledApplicationException {} -> Severity
Error
    ErrorPolicyUnhandledConnectionException {} -> Severity
Error
    ErrorPolicyAcceptException {} -> Severity
Error


instance HasPrivacyAnnotation (WithDomainName DnsTrace)
instance HasSeverityAnnotation (WithDomainName DnsTrace) where
  getSeverityAnnotation :: WithDomainName DnsTrace -> Severity
getSeverityAnnotation (WithDomainName Domain
_ DnsTrace
ev) = case DnsTrace
ev of
    DnsTraceLookupException {} -> Severity
Error
    DnsTraceLookupAError {} -> Severity
Error
    DnsTraceLookupAAAAError {} -> Severity
Error
    DnsTrace
DnsTraceLookupIPv6First -> Severity
Debug
    DnsTrace
DnsTraceLookupIPv4First -> Severity
Debug
    DnsTraceLookupAResult {} -> Severity
Debug
    DnsTraceLookupAAAAResult {} -> Severity
Debug


instance HasPrivacyAnnotation (WithDomainName (SubscriptionTrace SockAddr))
instance HasSeverityAnnotation (WithDomainName (SubscriptionTrace SockAddr)) where
  getSeverityAnnotation :: WithDomainName (SubscriptionTrace RemoteAddress) -> Severity
getSeverityAnnotation (WithDomainName Domain
_ SubscriptionTrace RemoteAddress
ev) = case SubscriptionTrace RemoteAddress
ev of
    SubscriptionTraceConnectStart {} -> Severity
Notice
    SubscriptionTraceConnectEnd {} -> Severity
Notice
    SubscriptionTraceConnectException RemoteAddress
_ e
e ->
        case SomeException -> Maybe SubscriberError
forall e. Exception e => SomeException -> Maybe e
fromException (SomeException -> Maybe SubscriberError)
-> SomeException -> Maybe SubscriberError
forall a b. (a -> b) -> a -> b
$ e -> SomeException
forall e. Exception e => e -> SomeException
SomeException e
e of
             Just (SubscriberError
_::SubscriberError) -> Severity
Debug
             Maybe SubscriberError
Nothing -> Severity
Error
    SubscriptionTraceSocketAllocationException {} -> Severity
Error
    SubscriptionTraceTryConnectToPeer {} -> Severity
Info
    SubscriptionTraceSkippingPeer {} -> Severity
Info
    SubscriptionTrace RemoteAddress
SubscriptionTraceSubscriptionRunning -> Severity
Debug
    SubscriptionTraceSubscriptionWaiting {} -> Severity
Debug
    SubscriptionTrace RemoteAddress
SubscriptionTraceSubscriptionFailed -> Severity
Warning
    SubscriptionTraceSubscriptionWaitingNewConnection {} -> Severity
Debug
    SubscriptionTraceStart {} -> Severity
Debug
    SubscriptionTraceRestart {} -> Severity
Debug
    SubscriptionTraceConnectionExist {} -> Severity
Info
    SubscriptionTraceUnsupportedRemoteAddr {} -> Severity
Warning
    SubscriptionTrace RemoteAddress
SubscriptionTraceMissingLocalAddress -> Severity
Warning
    SubscriptionTraceApplicationException RemoteAddress
_ e
e ->
        case SomeException -> Maybe SubscriberError
forall e. Exception e => SomeException -> Maybe e
fromException (SomeException -> Maybe SubscriberError)
-> SomeException -> Maybe SubscriberError
forall a b. (a -> b) -> a -> b
$ e -> SomeException
forall e. Exception e => e -> SomeException
SomeException e
e of
             Just (SubscriberError
_::SubscriberError) -> Severity
Debug
             Maybe SubscriberError
Nothing -> Severity
Error
    SubscriptionTraceAllocateSocket {} -> Severity
Debug
    SubscriptionTraceCloseSocket {} -> Severity
Debug


instance HasPrivacyAnnotation (WithIPList (SubscriptionTrace SockAddr))
instance HasSeverityAnnotation (WithIPList (SubscriptionTrace SockAddr)) where
  getSeverityAnnotation :: WithIPList (SubscriptionTrace RemoteAddress) -> Severity
getSeverityAnnotation (WithIPList LocalAddresses RemoteAddress
_ [RemoteAddress]
_ SubscriptionTrace RemoteAddress
ev) = case SubscriptionTrace RemoteAddress
ev of
    SubscriptionTraceConnectStart RemoteAddress
_ -> Severity
Info
    SubscriptionTraceConnectEnd RemoteAddress
_ ConnectResult
connectResult -> case ConnectResult
connectResult of
      ConnectResult
ConnectSuccess -> Severity
Info
      ConnectResult
ConnectSuccessLast -> Severity
Notice
      ConnectResult
ConnectValencyExceeded -> Severity
Warning
    SubscriptionTraceConnectException RemoteAddress
_ e
e ->
        case SomeException -> Maybe SubscriberError
forall e. Exception e => SomeException -> Maybe e
fromException (SomeException -> Maybe SubscriberError)
-> SomeException -> Maybe SubscriberError
forall a b. (a -> b) -> a -> b
$ e -> SomeException
forall e. Exception e => e -> SomeException
SomeException e
e of
             Just (SubscriberError
_::SubscriberError) -> Severity
Debug
             Maybe SubscriberError
Nothing -> Severity
Error
    SubscriptionTraceSocketAllocationException {} -> Severity
Error
    SubscriptionTraceTryConnectToPeer {} -> Severity
Info
    SubscriptionTraceSkippingPeer {} -> Severity
Info
    SubscriptionTrace RemoteAddress
SubscriptionTraceSubscriptionRunning -> Severity
Debug
    SubscriptionTraceSubscriptionWaiting {} -> Severity
Debug
    SubscriptionTrace RemoteAddress
SubscriptionTraceSubscriptionFailed -> Severity
Error
    SubscriptionTraceSubscriptionWaitingNewConnection {} -> Severity
Notice
    SubscriptionTraceStart {} -> Severity
Debug
    SubscriptionTraceRestart {} -> Severity
Info
    SubscriptionTraceConnectionExist {} -> Severity
Notice
    SubscriptionTraceUnsupportedRemoteAddr {} -> Severity
Error
    SubscriptionTrace RemoteAddress
SubscriptionTraceMissingLocalAddress -> Severity
Warning
    SubscriptionTraceApplicationException RemoteAddress
_ e
e ->
        case SomeException -> Maybe SubscriberError
forall e. Exception e => SomeException -> Maybe e
fromException (SomeException -> Maybe SubscriberError)
-> SomeException -> Maybe SubscriberError
forall a b. (a -> b) -> a -> b
$ e -> SomeException
forall e. Exception e => e -> SomeException
SomeException e
e of
             Just (SubscriberError
_::SubscriberError) -> Severity
Debug
             Maybe SubscriberError
Nothing -> Severity
Error
    SubscriptionTraceAllocateSocket {} -> Severity
Debug
    SubscriptionTraceCloseSocket {} -> Severity
Info


instance HasPrivacyAnnotation (Identity (SubscriptionTrace LocalAddress))
instance HasSeverityAnnotation (Identity (SubscriptionTrace LocalAddress)) where
  getSeverityAnnotation :: Identity (SubscriptionTrace LocalAddress) -> Severity
getSeverityAnnotation (Identity SubscriptionTrace LocalAddress
ev) = case SubscriptionTrace LocalAddress
ev of
    SubscriptionTraceConnectStart {} -> Severity
Notice
    SubscriptionTraceConnectEnd {} -> Severity
Notice
    SubscriptionTraceConnectException {} -> Severity
Error
    SubscriptionTraceSocketAllocationException {} -> Severity
Error
    SubscriptionTraceTryConnectToPeer {} -> Severity
Notice
    SubscriptionTraceSkippingPeer {} -> Severity
Info
    SubscriptionTrace LocalAddress
SubscriptionTraceSubscriptionRunning -> Severity
Notice
    SubscriptionTraceSubscriptionWaiting {} -> Severity
Debug
    SubscriptionTrace LocalAddress
SubscriptionTraceSubscriptionFailed -> Severity
Warning
    SubscriptionTraceSubscriptionWaitingNewConnection {} -> Severity
Debug
    SubscriptionTraceStart {} -> Severity
Notice
    SubscriptionTraceRestart {} -> Severity
Notice
    SubscriptionTraceConnectionExist {} -> Severity
Debug
    SubscriptionTraceUnsupportedRemoteAddr {} -> Severity
Warning
    SubscriptionTrace LocalAddress
SubscriptionTraceMissingLocalAddress -> Severity
Warning
    SubscriptionTraceApplicationException {} -> Severity
Error
    SubscriptionTraceAllocateSocket {} -> Severity
Debug
    SubscriptionTraceCloseSocket {} -> Severity
Debug


instance Transformable Text IO (Identity (SubscriptionTrace LocalAddress)) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer IO (Identity (SubscriptionTrace LocalAddress))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer IO (Identity (SubscriptionTrace LocalAddress))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter (Identity (SubscriptionTrace LocalAddress)) where
  formatText :: Identity (SubscriptionTrace LocalAddress) -> Object -> Text
formatText Identity (SubscriptionTrace LocalAddress)
a Object
_ = String -> Text
pack (Identity (SubscriptionTrace LocalAddress) -> String
forall a. Show a => a -> String
show Identity (SubscriptionTrace LocalAddress)
a)


instance ToObject (Identity (SubscriptionTrace LocalAddress)) where
  toObject :: TracingVerbosity
-> Identity (SubscriptionTrace LocalAddress) -> Object
toObject TracingVerbosity
_verb (Identity SubscriptionTrace LocalAddress
ev) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (String
"SubscriptionTrace" :: String)
             , Key
"event" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SubscriptionTrace LocalAddress -> String
forall a. Show a => a -> String
show SubscriptionTrace LocalAddress
ev
             ]


instance HasPrivacyAnnotation (WithMuxBearer peer MuxTrace)
instance HasSeverityAnnotation (WithMuxBearer peer MuxTrace) where
  getSeverityAnnotation :: WithMuxBearer peer MuxTrace -> Severity
getSeverityAnnotation (WithMuxBearer peer
_ MuxTrace
ev) = case MuxTrace
ev of
    MuxTrace
MuxTraceRecvHeaderStart -> Severity
Debug
    MuxTraceRecvHeaderEnd {} -> Severity
Debug
    MuxTraceRecvStart {} -> Severity
Debug
    MuxTraceRecvEnd {} -> Severity
Debug
    MuxTraceSendStart {} -> Severity
Debug
    MuxTrace
MuxTraceSendEnd -> Severity
Debug
    MuxTraceState {} -> Severity
Info
    MuxTraceCleanExit {} -> Severity
Notice
    MuxTraceExceptionExit {} -> Severity
Notice
    MuxTraceChannelRecvStart {} -> Severity
Debug
    MuxTraceChannelRecvEnd {} -> Severity
Debug
    MuxTraceChannelSendStart {} -> Severity
Debug
    MuxTraceChannelSendEnd {} -> Severity
Debug
    MuxTrace
MuxTraceHandshakeStart -> Severity
Debug
    MuxTraceHandshakeClientEnd {} -> Severity
Info
    MuxTrace
MuxTraceHandshakeServerEnd -> Severity
Debug
    MuxTraceHandshakeClientError {} -> Severity
Error
    MuxTraceHandshakeServerError {} -> Severity
Error
    MuxTraceRecvDeltaQObservation {} -> Severity
Debug
    MuxTraceRecvDeltaQSample {} -> Severity
Debug
    MuxTrace
MuxTraceSDUReadTimeoutException -> Severity
Notice
    MuxTrace
MuxTraceSDUWriteTimeoutException -> Severity
Notice
    MuxTraceStartEagerly MiniProtocolNum
_ MiniProtocolDir
_ -> Severity
Info
    MuxTraceStartOnDemand MiniProtocolNum
_ MiniProtocolDir
_ -> Severity
Info
    MuxTraceStartedOnDemand MiniProtocolNum
_ MiniProtocolDir
_ -> Severity
Info
    MuxTrace
MuxTraceShutdown -> Severity
Debug
    MuxTraceTerminating {} -> Severity
Debug
    MuxTraceTCPInfo {} -> Severity
Debug

instance HasPrivacyAnnotation (TraceLocalRootPeers RemoteAddress exception)
instance HasSeverityAnnotation (TraceLocalRootPeers RemoteAddress exception) where
  getSeverityAnnotation :: TraceLocalRootPeers RemoteAddress exception -> Severity
getSeverityAnnotation TraceLocalRootPeers RemoteAddress exception
_ = Severity
Info

instance HasPrivacyAnnotation TracePublicRootPeers
instance HasSeverityAnnotation TracePublicRootPeers where
  getSeverityAnnotation :: TracePublicRootPeers -> Severity
getSeverityAnnotation TracePublicRootPeers
_ = Severity
Info

instance HasPrivacyAnnotation (TracePeerSelection addr)
instance HasSeverityAnnotation (TracePeerSelection addr) where
  getSeverityAnnotation :: TracePeerSelection addr -> Severity
getSeverityAnnotation TracePeerSelection addr
ev =
    case TracePeerSelection addr
ev of
      TraceLocalRootPeersChanged {} -> Severity
Notice
      TraceTargetsChanged        {} -> Severity
Notice
      TracePublicRootsRequest    {} -> Severity
Info
      TracePublicRootsResults    {} -> Severity
Info
      TracePublicRootsFailure    {} -> Severity
Error
      TraceGossipRequests        {} -> Severity
Debug
      TraceGossipResults         {} -> Severity
Debug
      TraceForgetColdPeers       {} -> Severity
Info
      TracePromoteColdPeers      {} -> Severity
Info
      TracePromoteColdLocalPeers {} -> Severity
Info
      TracePromoteColdFailed     {} -> Severity
Info
      TracePromoteColdDone       {} -> Severity
Info
      TracePromoteWarmPeers      {} -> Severity
Info
      TracePromoteWarmLocalPeers {} -> Severity
Info
      TracePromoteWarmFailed     {} -> Severity
Info
      TracePromoteWarmDone       {} -> Severity
Info
      TracePromoteWarmAborted    {} -> Severity
Info
      TraceDemoteWarmPeers       {} -> Severity
Info
      TraceDemoteWarmFailed      {} -> Severity
Info
      TraceDemoteWarmDone        {} -> Severity
Info
      TraceDemoteHotPeers        {} -> Severity
Info
      TraceDemoteLocalHotPeers   {} -> Severity
Info
      TraceDemoteHotFailed       {} -> Severity
Info
      TraceDemoteHotDone         {} -> Severity
Info
      TraceDemoteAsynchronous    {} -> Severity
Info
      TraceGovernorWakeup        {} -> Severity
Info
      TraceChurnWait             {} -> Severity
Info
      TraceChurnMode             {} -> Severity
Info

instance HasPrivacyAnnotation (DebugPeerSelection addr)
instance HasSeverityAnnotation (DebugPeerSelection addr) where
  getSeverityAnnotation :: DebugPeerSelection addr -> Severity
getSeverityAnnotation DebugPeerSelection addr
_ = Severity
Debug

instance HasPrivacyAnnotation (PeerSelectionActionsTrace SockAddr)
instance HasSeverityAnnotation (PeerSelectionActionsTrace SockAddr) where
  getSeverityAnnotation :: PeerSelectionActionsTrace RemoteAddress -> Severity
getSeverityAnnotation PeerSelectionActionsTrace RemoteAddress
ev =
   case PeerSelectionActionsTrace RemoteAddress
ev of
     PeerStatusChanged {}       -> Severity
Info
     PeerStatusChangeFailure {} -> Severity
Error
     PeerMonitoringError {}     -> Severity
Error
     PeerMonitoringResult {}    -> Severity
Debug

instance HasPrivacyAnnotation PeerSelectionCounters
instance HasSeverityAnnotation PeerSelectionCounters where
  getSeverityAnnotation :: PeerSelectionCounters -> Severity
getSeverityAnnotation PeerSelectionCounters
_ = Severity
Info

instance HasPrivacyAnnotation (ConnectionManagerTrace addr connTrace)
instance HasSeverityAnnotation (ConnectionManagerTrace addr (ConnectionHandlerTrace versionNumber agreedOptions)) where
  getSeverityAnnotation :: ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
-> Severity
getSeverityAnnotation ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
ev =
    case ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
ev of
      TrIncludeConnection {}                  -> Severity
Debug
      TrUnregisterConnection {}               -> Severity
Debug
      TrConnect {}                            -> Severity
Debug
      TrConnectError {}                       -> Severity
Info
      TrTerminatingConnection {}              -> Severity
Debug
      TrTerminatedConnection {}               -> Severity
Debug
      TrConnectionHandler ConnectionId addr
_ ConnectionHandlerTrace versionNumber agreedOptions
ev'     ->
        case ConnectionHandlerTrace versionNumber agreedOptions
ev' of
          TrHandshakeSuccess {}               -> Severity
Info
          TrHandshakeClientError {}           -> Severity
Notice
          TrHandshakeServerError {}           -> Severity
Info
          TrError ErrorContext
_ SomeException
_ ErrorCommand
ShutdownNode            -> Severity
Critical
          TrError ErrorContext
_ SomeException
_ ErrorCommand
ShutdownPeer            -> Severity
Info

      ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
TrShutdown                              -> Severity
Info
      TrConnectionExists {}                   -> Severity
Info
      TrForbiddenConnection {}                -> Severity
Info
      TrImpossibleConnection {}               -> Severity
Info
      TrConnectionFailure {}                  -> Severity
Info
      TrConnectionNotFound {}                 -> Severity
Debug
      TrForbiddenOperation {}                 -> Severity
Info

      TrPruneConnections {}                   -> Severity
Notice
      TrConnectionCleanup {}                  -> Severity
Debug
      TrConnectionTimeWait {}                 -> Severity
Debug
      TrConnectionTimeWaitDone {}             -> Severity
Debug
      TrConnectionManagerCounters {}          -> Severity
Info
      TrState {}                              -> Severity
Info
      ConnMgr.TrUnexpectedlyFalseAssertion {} -> Severity
Error

instance HasPrivacyAnnotation (ConnMgr.AbstractTransitionTrace addr)
instance HasSeverityAnnotation (ConnMgr.AbstractTransitionTrace addr) where
  getSeverityAnnotation :: AbstractTransitionTrace addr -> Severity
getSeverityAnnotation AbstractTransitionTrace addr
_ = Severity
Debug

instance HasPrivacyAnnotation (ServerTrace addr)
instance HasSeverityAnnotation (ServerTrace addr) where
  getSeverityAnnotation :: ServerTrace addr -> Severity
getSeverityAnnotation ServerTrace addr
ev =
    case ServerTrace addr
ev of
      Server.TrAcceptConnection {}                      -> Severity
Debug
      Server.TrAcceptError {}                           -> Severity
Error
      Server.TrAcceptPolicyTrace {}                     -> Severity
Notice
      Server.TrServerStarted {}                         -> Severity
Notice
      Server.TrServerStopped {}                         -> Severity
Notice
      Server.TrServerError {}                           -> Severity
Critical

instance HasPrivacyAnnotation (InboundGovernorTrace addr)
instance HasSeverityAnnotation (InboundGovernorTrace addr) where
  getSeverityAnnotation :: InboundGovernorTrace addr -> Severity
getSeverityAnnotation InboundGovernorTrace addr
ev =
    case InboundGovernorTrace addr
ev of
      InboundGovernor.TrNewConnection {}           -> Severity
Debug
      InboundGovernor.TrResponderRestarted {}      -> Severity
Debug
      InboundGovernor.TrResponderStartFailure {}   -> Severity
Error
      InboundGovernor.TrResponderErrored {}        -> Severity
Info
      InboundGovernor.TrResponderStarted {}        -> Severity
Debug
      InboundGovernor.TrResponderTerminated {}     -> Severity
Debug
      InboundGovernor.TrPromotedToWarmRemote {}    -> Severity
Info
      InboundGovernor.TrPromotedToHotRemote {}     -> Severity
Info
      InboundGovernor.TrDemotedToColdRemote {}     -> Severity
Info
      InboundGovernor.TrDemotedToWarmRemote {}     -> Severity
Info
      InboundGovernor.TrWaitIdleRemote {}          -> Severity
Debug
      InboundGovernor.TrMuxCleanExit {}            -> Severity
Debug
      InboundGovernor.TrMuxErrored {}              -> Severity
Info
      InboundGovernor.TrInboundGovernorCounters {} -> Severity
Info
      InboundGovernor.TrRemoteState {}             -> Severity
Debug
      InboundGovernor.TrUnexpectedlyFalseAssertion {}
                                                   -> Severity
Error
      InboundGovernor.TrInboundGovernorError {}    -> Severity
Error

instance HasPrivacyAnnotation (Server.RemoteTransitionTrace addr)
instance HasSeverityAnnotation (Server.RemoteTransitionTrace addr) where
  getSeverityAnnotation :: RemoteTransitionTrace addr -> Severity
getSeverityAnnotation RemoteTransitionTrace addr
_ = Severity
Debug

--
-- | instances of @Transformable@
--
-- NOTE: this list is sorted by the unqualified name of the outermost type.

instance Transformable Text IO (ND.InitializationTracer RemoteAddress LocalAddress) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer IO (InitializationTracer RemoteAddress LocalAddress)
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer IO (InitializationTracer RemoteAddress LocalAddress)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter (ND.InitializationTracer RemoteAddress LocalAddress) where
  formatText :: InitializationTracer RemoteAddress LocalAddress -> Object -> Text
formatText InitializationTracer RemoteAddress LocalAddress
a Object
_ = String -> Text
pack (InitializationTracer RemoteAddress LocalAddress -> String
forall a. Show a => a -> String
show InitializationTracer RemoteAddress LocalAddress
a)

instance Transformable Text IO (NtN.HandshakeTr RemoteAddress NodeToNodeVersion) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer IO (HandshakeTr RemoteAddress NodeToNodeVersion)
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer IO (HandshakeTr RemoteAddress NodeToNodeVersion)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter (NtN.HandshakeTr RemoteAddress NodeToNodeVersion) where
  formatText :: HandshakeTr RemoteAddress NodeToNodeVersion -> Object -> Text
formatText HandshakeTr RemoteAddress NodeToNodeVersion
a Object
_ = String -> Text
pack (HandshakeTr RemoteAddress NodeToNodeVersion -> String
forall a. Show a => a -> String
show HandshakeTr RemoteAddress NodeToNodeVersion
a)


instance Transformable Text IO (NtC.HandshakeTr LocalAddress NodeToClientVersion) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer IO (HandshakeTr LocalAddress NodeToClientVersion)
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer IO (HandshakeTr LocalAddress NodeToClientVersion)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter (NtC.HandshakeTr LocalAddress NodeToClientVersion) where
  formatText :: HandshakeTr LocalAddress NodeToClientVersion -> Object -> Text
formatText HandshakeTr LocalAddress NodeToClientVersion
a Object
_ = String -> Text
pack (HandshakeTr LocalAddress NodeToClientVersion -> String
forall a. Show a => a -> String
show HandshakeTr LocalAddress NodeToClientVersion
a)


instance Transformable Text IO NtN.AcceptConnectionsPolicyTrace where
  trTransformer :: TracingVerbosity
-> Trace IO Text -> Tracer IO AcceptConnectionsPolicyTrace
trTransformer = TracingVerbosity
-> Trace IO Text -> Tracer IO AcceptConnectionsPolicyTrace
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter NtN.AcceptConnectionsPolicyTrace where
  formatText :: AcceptConnectionsPolicyTrace -> Object -> Text
formatText AcceptConnectionsPolicyTrace
a Object
_ = String -> Text
pack (AcceptConnectionsPolicyTrace -> String
forall a. Show a => a -> String
show AcceptConnectionsPolicyTrace
a)


instance (StandardHash header, Show peer, ToObject peer)
      => Transformable Text IO [TraceLabelPeer peer (FetchDecision [Point header])] where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer IO [TraceLabelPeer peer (FetchDecision [Point header])]
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer IO [TraceLabelPeer peer (FetchDecision [Point header])]
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance (StandardHash header, Show peer)
      => HasTextFormatter [TraceLabelPeer peer (FetchDecision [Point header])] where
  formatText :: [TraceLabelPeer peer (FetchDecision [Point header])]
-> Object -> Text
formatText [TraceLabelPeer peer (FetchDecision [Point header])]
a Object
_ = String -> Text
pack ([TraceLabelPeer peer (FetchDecision [Point header])] -> String
forall a. Show a => a -> String
show [TraceLabelPeer peer (FetchDecision [Point header])]
a)

instance (HasHeader header, ConvertRawHash header, ToObject peer)
     => Transformable Text IO (TraceLabelPeer peer (TraceFetchClientState header)) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer IO (TraceLabelPeer peer (TraceFetchClientState header))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer IO (TraceLabelPeer peer (TraceFetchClientState header))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructured
instance (Show header, StandardHash header, Show peer)
     => HasTextFormatter (TraceLabelPeer peer (TraceFetchClientState header)) where
  formatText :: TraceLabelPeer peer (TraceFetchClientState header)
-> Object -> Text
formatText TraceLabelPeer peer (TraceFetchClientState header)
a Object
_ = String -> Text
pack (TraceLabelPeer peer (TraceFetchClientState header) -> String
forall a. Show a => a -> String
show TraceLabelPeer peer (TraceFetchClientState header)
a)

instance ToObject peer
     => Transformable Text IO (TraceLabelPeer peer (NtN.TraceSendRecv (ChainSync (Header blk) (Point blk) (Tip blk)))) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        peer
        (TraceSendRecv (ChainSync (Header blk) (Point blk) (Tip blk))))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        peer
        (TraceSendRecv (ChainSync (Header blk) (Point blk) (Tip blk))))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructured
instance (Show peer, StandardHash blk, Show (Header blk))
     => HasTextFormatter (TraceLabelPeer peer (NtN.TraceSendRecv (ChainSync (Header blk) (Point blk) (Tip blk)))) where
  formatText :: TraceLabelPeer
  peer (TraceSendRecv (ChainSync (Header blk) (Point blk) (Tip blk)))
-> Object -> Text
formatText TraceLabelPeer
  peer (TraceSendRecv (ChainSync (Header blk) (Point blk) (Tip blk)))
a Object
_ = String -> Text
pack (TraceLabelPeer
  peer (TraceSendRecv (ChainSync (Header blk) (Point blk) (Tip blk)))
-> String
forall a. Show a => a -> String
show TraceLabelPeer
  peer (TraceSendRecv (ChainSync (Header blk) (Point blk) (Tip blk)))
a)

instance (ToObject peer, ToObject (AnyMessageAndAgency (TraceTxSubmissionInbound (GenTxId blk) (GenTx blk))))
     => Transformable Text IO (TraceLabelPeer peer (NtN.TraceSendRecv (TraceTxSubmissionInbound  (GenTxId blk) (GenTx blk)))) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        peer
        (TraceSendRecv
           (TraceTxSubmissionInbound (GenTxId blk) (GenTx blk))))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        peer
        (TraceSendRecv
           (TraceTxSubmissionInbound (GenTxId blk) (GenTx blk))))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructured

instance ToObject peer
     => Transformable Text IO (TraceLabelPeer peer (TraceTxSubmissionInbound  (GenTxId blk) (GenTx blk))) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        peer (TraceTxSubmissionInbound (GenTxId blk) (GenTx blk)))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        peer (TraceTxSubmissionInbound (GenTxId blk) (GenTx blk)))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructured

instance (ToObject peer, ConvertTxId blk, RunNode blk, HasTxs blk)
     => Transformable Text IO (TraceLabelPeer peer (NtN.TraceSendRecv (BlockFetch blk (Point blk)))) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer peer (TraceSendRecv (BlockFetch blk (Point blk))))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer peer (TraceSendRecv (BlockFetch blk (Point blk))))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructured

instance ToObject localPeer
     => Transformable Text IO (TraceLabelPeer localPeer (NtN.TraceSendRecv (ChainSync (Serialised blk) (Point blk) (Tip blk)))) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        localPeer
        (TraceSendRecv (ChainSync (Serialised blk) (Point blk) (Tip blk))))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        localPeer
        (TraceSendRecv (ChainSync (Serialised blk) (Point blk) (Tip blk))))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructured

instance (applyTxErr ~ ApplyTxErr blk, ToObject localPeer)
     => Transformable Text IO (TraceLabelPeer localPeer (NtN.TraceSendRecv (LocalTxMonitor (GenTxId blk) (GenTx blk) SlotNo))) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        localPeer
        (TraceSendRecv (LocalTxMonitor (GenTxId blk) (GenTx blk) SlotNo)))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        localPeer
        (TraceSendRecv (LocalTxMonitor (GenTxId blk) (GenTx blk) SlotNo)))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructured

instance (applyTxErr ~ ApplyTxErr blk, ToObject localPeer)
     => Transformable Text IO (TraceLabelPeer localPeer (NtN.TraceSendRecv (LocalTxSubmission (GenTx blk) applyTxErr))) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        localPeer
        (TraceSendRecv (LocalTxSubmission (GenTx blk) applyTxErr)))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        localPeer
        (TraceSendRecv (LocalTxSubmission (GenTx blk) applyTxErr)))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructured

instance (LocalStateQuery.ShowQuery (BlockQuery blk), ToObject localPeer)
     => Transformable Text IO (TraceLabelPeer localPeer (NtN.TraceSendRecv (LocalStateQuery blk (Point blk) (Query blk)))) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        localPeer
        (TraceSendRecv (LocalStateQuery blk (Point blk) (Query blk))))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        localPeer
        (TraceSendRecv (LocalStateQuery blk (Point blk) (Query blk))))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructured

instance (ToObject peer, Show (TxId (GenTx blk)), Show (GenTx blk))
     => Transformable Text IO (TraceLabelPeer peer (NtN.TraceSendRecv (TxSubmission2 (GenTxId blk) (GenTx blk)))) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        peer (TraceSendRecv (TxSubmission2 (GenTxId blk) (GenTx blk))))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        peer (TraceSendRecv (TxSubmission2 (GenTxId blk) (GenTx blk))))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructured

instance (ToObject peer, Show (TxId (GenTx blk)), Show (GenTx blk))
     => Transformable Text IO (TraceLabelPeer peer (TraceTxSubmissionOutbound (GenTxId blk) (GenTx blk))) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        peer (TraceTxSubmissionOutbound (GenTxId blk) (GenTx blk)))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (TraceLabelPeer
        peer (TraceTxSubmissionOutbound (GenTxId blk) (GenTx blk)))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructured

instance Transformable Text IO (TraceTxSubmissionInbound txid tx) where
  trTransformer :: TracingVerbosity
-> Trace IO Text -> Tracer IO (TraceTxSubmissionInbound txid tx)
trTransformer = TracingVerbosity
-> Trace IO Text -> Tracer IO (TraceTxSubmissionInbound txid tx)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter (TraceTxSubmissionInbound txid tx) where
  formatText :: TraceTxSubmissionInbound txid tx -> Object -> Text
formatText TraceTxSubmissionInbound txid tx
a Object
_ = String -> Text
pack (TraceTxSubmissionInbound txid tx -> String
forall a. Show a => a -> String
show TraceTxSubmissionInbound txid tx
a)


instance (Show tx, Show txid)
      => Transformable Text IO (TraceTxSubmissionOutbound txid tx) where
  trTransformer :: TracingVerbosity
-> Trace IO Text -> Tracer IO (TraceTxSubmissionOutbound txid tx)
trTransformer = TracingVerbosity
-> Trace IO Text -> Tracer IO (TraceTxSubmissionOutbound txid tx)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance (Show tx, Show txid)
      => HasTextFormatter (TraceTxSubmissionOutbound txid tx) where
  formatText :: TraceTxSubmissionOutbound txid tx -> Object -> Text
formatText TraceTxSubmissionOutbound txid tx
a Object
_ = String -> Text
pack (TraceTxSubmissionOutbound txid tx -> String
forall a. Show a => a -> String
show TraceTxSubmissionOutbound txid tx
a)


instance Show addr
      => Transformable Text IO (TraceKeepAliveClient addr) where
  trTransformer :: TracingVerbosity
-> Trace IO Text -> Tracer IO (TraceKeepAliveClient addr)
trTransformer = TracingVerbosity
-> Trace IO Text -> Tracer IO (TraceKeepAliveClient addr)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance Show addr
      => HasTextFormatter (TraceKeepAliveClient addr) where
    formatText :: TraceKeepAliveClient addr -> Object -> Text
formatText TraceKeepAliveClient addr
a Object
_ = String -> Text
pack (TraceKeepAliveClient addr -> String
forall a. Show a => a -> String
show TraceKeepAliveClient addr
a)


instance Transformable Text IO TraceLedgerPeers where
  trTransformer :: TracingVerbosity -> Trace IO Text -> Tracer IO TraceLedgerPeers
trTransformer = TracingVerbosity -> Trace IO Text -> Tracer IO TraceLedgerPeers
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter TraceLedgerPeers where
  formatText :: TraceLedgerPeers -> Object -> Text
formatText TraceLedgerPeers
_ = String -> Text
pack (String -> Text) -> (Object -> String) -> Object -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [Value] -> String
forall a. Show a => a -> String
show ([Value] -> String) -> (Object -> [Value]) -> Object -> String
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Object -> [Value]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList


instance Show addr => Transformable Text IO (WithAddr addr ErrorPolicyTrace) where
  trTransformer :: TracingVerbosity
-> Trace IO Text -> Tracer IO (WithAddr addr ErrorPolicyTrace)
trTransformer = TracingVerbosity
-> Trace IO Text -> Tracer IO (WithAddr addr ErrorPolicyTrace)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance Show addr => HasTextFormatter (WithAddr addr ErrorPolicyTrace) where
  formatText :: WithAddr addr ErrorPolicyTrace -> Object -> Text
formatText WithAddr addr ErrorPolicyTrace
a Object
_ = String -> Text
pack (WithAddr addr ErrorPolicyTrace -> String
forall a. Show a => a -> String
show WithAddr addr ErrorPolicyTrace
a)


instance Transformable Text IO (WithDomainName (SubscriptionTrace SockAddr)) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer IO (WithDomainName (SubscriptionTrace RemoteAddress))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer IO (WithDomainName (SubscriptionTrace RemoteAddress))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter (WithDomainName (SubscriptionTrace SockAddr)) where
  formatText :: WithDomainName (SubscriptionTrace RemoteAddress) -> Object -> Text
formatText WithDomainName (SubscriptionTrace RemoteAddress)
a Object
_ = String -> Text
pack (WithDomainName (SubscriptionTrace RemoteAddress) -> String
forall a. Show a => a -> String
show WithDomainName (SubscriptionTrace RemoteAddress)
a)


instance Transformable Text IO (WithDomainName DnsTrace) where
  trTransformer :: TracingVerbosity
-> Trace IO Text -> Tracer IO (WithDomainName DnsTrace)
trTransformer = TracingVerbosity
-> Trace IO Text -> Tracer IO (WithDomainName DnsTrace)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter (WithDomainName DnsTrace) where
  formatText :: WithDomainName DnsTrace -> Object -> Text
formatText WithDomainName DnsTrace
a Object
_ = String -> Text
pack (WithDomainName DnsTrace -> String
forall a. Show a => a -> String
show WithDomainName DnsTrace
a)


instance Transformable Text IO (WithIPList (SubscriptionTrace SockAddr)) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer IO (WithIPList (SubscriptionTrace RemoteAddress))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer IO (WithIPList (SubscriptionTrace RemoteAddress))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter (WithIPList (SubscriptionTrace SockAddr)) where
  formatText :: WithIPList (SubscriptionTrace RemoteAddress) -> Object -> Text
formatText WithIPList (SubscriptionTrace RemoteAddress)
a Object
_ = String -> Text
pack (WithIPList (SubscriptionTrace RemoteAddress) -> String
forall a. Show a => a -> String
show WithIPList (SubscriptionTrace RemoteAddress)
a)


instance (Show peer, ToObject peer)
      => Transformable Text IO (WithMuxBearer peer MuxTrace) where
  trTransformer :: TracingVerbosity
-> Trace IO Text -> Tracer IO (WithMuxBearer peer MuxTrace)
trTransformer = TracingVerbosity
-> Trace IO Text -> Tracer IO (WithMuxBearer peer MuxTrace)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance (Show peer)
      => HasTextFormatter (WithMuxBearer peer MuxTrace) where
  formatText :: WithMuxBearer peer MuxTrace -> Object -> Text
formatText (WithMuxBearer peer
peer MuxTrace
ev) = \Object
_o ->
        Text
"Bearer on " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
pack (peer -> String
forall a. Show a => a -> String
show peer
peer)
     Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" event: " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
pack (MuxTrace -> String
forall a. Show a => a -> String
show MuxTrace
ev)


instance Show exception => Transformable Text IO (TraceLocalRootPeers RemoteAddress exception) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer IO (TraceLocalRootPeers RemoteAddress exception)
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer IO (TraceLocalRootPeers RemoteAddress exception)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance Show exception => HasTextFormatter (TraceLocalRootPeers RemoteAddress exception) where
    formatText :: TraceLocalRootPeers RemoteAddress exception -> Object -> Text
formatText TraceLocalRootPeers RemoteAddress exception
a Object
_ = String -> Text
pack (TraceLocalRootPeers RemoteAddress exception -> String
forall a. Show a => a -> String
show TraceLocalRootPeers RemoteAddress exception
a)

instance Transformable Text IO TracePublicRootPeers where
  trTransformer :: TracingVerbosity -> Trace IO Text -> Tracer IO TracePublicRootPeers
trTransformer = TracingVerbosity -> Trace IO Text -> Tracer IO TracePublicRootPeers
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter TracePublicRootPeers where
  formatText :: TracePublicRootPeers -> Object -> Text
formatText TracePublicRootPeers
a Object
_ = String -> Text
pack (TracePublicRootPeers -> String
forall a. Show a => a -> String
show TracePublicRootPeers
a)

instance Transformable Text IO (TracePeerSelection SockAddr) where
  trTransformer :: TracingVerbosity
-> Trace IO Text -> Tracer IO (TracePeerSelection RemoteAddress)
trTransformer = TracingVerbosity
-> Trace IO Text -> Tracer IO (TracePeerSelection RemoteAddress)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter (TracePeerSelection SockAddr) where
  formatText :: TracePeerSelection RemoteAddress -> Object -> Text
formatText TracePeerSelection RemoteAddress
a Object
_ = String -> Text
pack (TracePeerSelection RemoteAddress -> String
forall a. Show a => a -> String
show TracePeerSelection RemoteAddress
a)

instance Transformable Text IO (DebugPeerSelection SockAddr) where
  trTransformer :: TracingVerbosity
-> Trace IO Text -> Tracer IO (DebugPeerSelection RemoteAddress)
trTransformer = TracingVerbosity
-> Trace IO Text -> Tracer IO (DebugPeerSelection RemoteAddress)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter (DebugPeerSelection SockAddr) where
  -- One can only change what is logged with respect to verbosity using json
  -- format.
  formatText :: DebugPeerSelection RemoteAddress -> Object -> Text
formatText DebugPeerSelection RemoteAddress
_ Object
obj = String -> Text
pack (Object -> String
forall a. Show a => a -> String
show Object
obj)

instance Transformable Text IO (PeerSelectionActionsTrace SockAddr) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer IO (PeerSelectionActionsTrace RemoteAddress)
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer IO (PeerSelectionActionsTrace RemoteAddress)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter (PeerSelectionActionsTrace SockAddr) where
  formatText :: PeerSelectionActionsTrace RemoteAddress -> Object -> Text
formatText PeerSelectionActionsTrace RemoteAddress
a Object
_ = String -> Text
pack (PeerSelectionActionsTrace RemoteAddress -> String
forall a. Show a => a -> String
show PeerSelectionActionsTrace RemoteAddress
a)

instance Transformable Text IO PeerSelectionCounters where
  trTransformer :: TracingVerbosity
-> Trace IO Text -> Tracer IO PeerSelectionCounters
trTransformer = TracingVerbosity
-> Trace IO Text -> Tracer IO PeerSelectionCounters
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance HasTextFormatter PeerSelectionCounters where
  formatText :: PeerSelectionCounters -> Object -> Text
formatText PeerSelectionCounters
a Object
_ = String -> Text
pack (PeerSelectionCounters -> String
forall a. Show a => a -> String
show PeerSelectionCounters
a)

instance (Show addr, Show versionNumber, Show agreedOptions, ToObject addr,
          ToJSON addr, ToJSON versionNumber, ToJSON agreedOptions
         )
      => Transformable Text IO (ConnectionManagerTrace
                                 addr
                                 (ConnectionHandlerTrace versionNumber agreedOptions)) where
  trTransformer :: TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (ConnectionManagerTrace
        addr (ConnectionHandlerTrace versionNumber agreedOptions))
trTransformer = TracingVerbosity
-> Trace IO Text
-> Tracer
     IO
     (ConnectionManagerTrace
        addr (ConnectionHandlerTrace versionNumber agreedOptions))
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance (Show addr, Show versionNumber, Show agreedOptions)
      => HasTextFormatter (ConnectionManagerTrace
                            addr
                            (ConnectionHandlerTrace versionNumber agreedOptions)) where
  formatText :: ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
-> Object -> Text
formatText ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
a Object
_ = String -> Text
pack (ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
-> String
forall a. Show a => a -> String
show ConnectionManagerTrace
  addr (ConnectionHandlerTrace versionNumber agreedOptions)
a)

instance (Show addr, ToJSON addr, ToObject addr)
      => Transformable Text IO (ConnMgr.AbstractTransitionTrace addr) where
  trTransformer :: TracingVerbosity
-> Trace IO Text -> Tracer IO (AbstractTransitionTrace addr)
trTransformer = TracingVerbosity
-> Trace IO Text -> Tracer IO (AbstractTransitionTrace addr)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance Show addr
      => HasTextFormatter (ConnMgr.AbstractTransitionTrace addr) where
  formatText :: AbstractTransitionTrace addr -> Object -> Text
formatText AbstractTransitionTrace addr
a Object
_ = String -> Text
pack (AbstractTransitionTrace addr -> String
forall a. Show a => a -> String
show AbstractTransitionTrace addr
a)

instance (Show addr, ToObject addr, ToJSON addr)
      => Transformable Text IO (ServerTrace addr) where
  trTransformer :: TracingVerbosity -> Trace IO Text -> Tracer IO (ServerTrace addr)
trTransformer = TracingVerbosity -> Trace IO Text -> Tracer IO (ServerTrace addr)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance Show addr
      => HasTextFormatter (ServerTrace addr) where
  formatText :: ServerTrace addr -> Object -> Text
formatText ServerTrace addr
a Object
_ = String -> Text
pack (ServerTrace addr -> String
forall a. Show a => a -> String
show ServerTrace addr
a)

instance (ToJSON addr, Show addr)
      => Transformable Text IO (InboundGovernorTrace addr) where
  trTransformer :: TracingVerbosity
-> Trace IO Text -> Tracer IO (InboundGovernorTrace addr)
trTransformer = TracingVerbosity
-> Trace IO Text -> Tracer IO (InboundGovernorTrace addr)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance Show addr
      => HasTextFormatter (InboundGovernorTrace addr) where
  formatText :: InboundGovernorTrace addr -> Object -> Text
formatText InboundGovernorTrace addr
a Object
_ = String -> Text
pack (InboundGovernorTrace addr -> String
forall a. Show a => a -> String
show InboundGovernorTrace addr
a)

instance (Show addr, ToJSON addr)
      => Transformable Text IO (Server.RemoteTransitionTrace addr) where
  trTransformer :: TracingVerbosity
-> Trace IO Text -> Tracer IO (RemoteTransitionTrace addr)
trTransformer = TracingVerbosity
-> Trace IO Text -> Tracer IO (RemoteTransitionTrace addr)
forall b (m :: * -> *) a.
(ToObject b, MonadIO m, HasTextFormatter b, HasPrivacyAnnotation b,
 HasSeverityAnnotation b) =>
TracingVerbosity -> Trace m a -> Tracer m b
trStructuredText
instance Show addr
      => HasTextFormatter (Server.RemoteTransitionTrace addr) where
  formatText :: RemoteTransitionTrace addr -> Object -> Text
formatText RemoteTransitionTrace addr
a Object
_ = String -> Text
pack (RemoteTransitionTrace addr -> String
forall a. Show a => a -> String
show RemoteTransitionTrace addr
a)

--
-- | instances of @ToObject@
--
-- NOTE: this list is sorted by the unqualified name of the outermost type.

instance ( ConvertTxId blk
         , RunNode blk
         , HasTxs blk
         )
      => ToObject (AnyMessageAndAgency (BlockFetch blk (Point blk))) where
  toObject :: TracingVerbosity
-> AnyMessageAndAgency (BlockFetch blk (Point blk)) -> Object
toObject TracingVerbosity
MinimalVerbosity (AnyMessageAndAgency PeerHasAgency pr st
stok (MsgBlock blk)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgBlock"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             , Key
"blockHash" Key -> Text -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Proxy blk -> HeaderHash blk -> Text
forall blk (proxy :: * -> *).
ConvertRawHash blk =>
proxy blk -> HeaderHash blk -> Text
renderHeaderHash (Proxy blk
forall k (t :: k). Proxy t
Proxy @blk) (block1 -> HeaderHash block1
forall b. HasHeader b => b -> HeaderHash b
blockHash block1
blk)
             , Key
"blockSize" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SizeInBytes -> Value
forall a. ToJSON a => a -> Value
toJSON (Header block1 -> SizeInBytes
forall blk.
SerialiseNodeToNodeConstraints blk =>
Header blk -> SizeInBytes
estimateBlockSize (block1 -> Header block1
forall blk. GetHeader blk => blk -> Header blk
getHeader block1
blk))
             ]

  toObject TracingVerbosity
verb (AnyMessageAndAgency PeerHasAgency pr st
stok (MsgBlock blk)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgBlock"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             , Key
"blockHash" Key -> Text -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Proxy blk -> HeaderHash blk -> Text
forall blk (proxy :: * -> *).
ConvertRawHash blk =>
proxy blk -> HeaderHash blk -> Text
renderHeaderHash (Proxy blk
forall k (t :: k). Proxy t
Proxy @blk) (block1 -> HeaderHash block1
forall b. HasHeader b => b -> HeaderHash b
blockHash block1
blk)
             , Key
"blockSize" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SizeInBytes -> Value
forall a. ToJSON a => a -> Value
toJSON (Header block1 -> SizeInBytes
forall blk.
SerialiseNodeToNodeConstraints blk =>
Header blk -> SizeInBytes
estimateBlockSize (block1 -> Header block1
forall blk. GetHeader blk => blk -> Header blk
getHeader block1
blk))
             , Key
"txIds" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Value] -> Value
forall a. ToJSON a => a -> Value
toJSON (GenTx blk -> Value
presentTx (GenTx blk -> Value) -> [GenTx blk] -> [Value]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> block1 -> [GenTx block1]
forall blk. HasTxs blk => blk -> [GenTx blk]
extractTxs block1
blk)
             ]
      where
        presentTx :: GenTx blk -> Value
        presentTx :: GenTx blk -> Value
presentTx =  Text -> Value
String (Text -> Value) -> (GenTx blk -> Text) -> GenTx blk -> Value
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TracingVerbosity -> TxId (GenTx blk) -> Text
forall blk.
ConvertTxId blk =>
TracingVerbosity -> TxId (GenTx blk) -> Text
renderTxIdForVerbosity TracingVerbosity
verb (TxId (GenTx blk) -> Text)
-> (GenTx blk -> TxId (GenTx blk)) -> GenTx blk -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. GenTx blk -> TxId (GenTx blk)
forall tx. HasTxId tx => tx -> TxId tx
txId

  toObject TracingVerbosity
_v (AnyMessageAndAgency PeerHasAgency pr st
stok MsgRequestRange{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgRequestRange"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_v (AnyMessageAndAgency PeerHasAgency pr st
stok MsgStartBatch{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgStartBatch"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_v (AnyMessageAndAgency PeerHasAgency pr st
stok MsgNoBlocks{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgNoBlocks"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_v (AnyMessageAndAgency PeerHasAgency pr st
stok MsgBatchDone{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgBatchDone"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_v (AnyMessageAndAgency PeerHasAgency pr st
stok MsgClientDone{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgClientDone"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]

instance (forall result. Show (query result))
      => ToObject (AnyMessageAndAgency (LocalStateQuery blk pt query)) where
  toObject :: TracingVerbosity
-> AnyMessageAndAgency (LocalStateQuery blk pt query) -> Object
toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalStateQuery.MsgAcquire{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgAcquire"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalStateQuery.MsgAcquired{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgAcquired"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalStateQuery.MsgFailure{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgFailure"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalStateQuery.MsgQuery{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgQuery"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalStateQuery.MsgResult{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgResult"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalStateQuery.MsgRelease{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgRelease"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalStateQuery.MsgReAcquire{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgReAcquire"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalStateQuery.MsgDone{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgDone"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]

instance ToObject (AnyMessageAndAgency (LocalTxMonitor txid tx slotno)) where
  toObject :: TracingVerbosity
-> AnyMessageAndAgency (LocalTxMonitor txid tx slotno) -> Object
toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxMonitor.MsgAcquire {}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgAcuire"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxMonitor.MsgAcquired {}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgAcuired"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxMonitor.MsgAwaitAcquire {}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgAwaitAcuire"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxMonitor.MsgNextTx {}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgNextTx"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxMonitor.MsgReplyNextTx {}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgReplyNextTx"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxMonitor.MsgHasTx {}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgHasTx"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxMonitor.MsgReplyHasTx {}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgReplyHasTx"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxMonitor.MsgGetSizes {}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgGetSizes"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxMonitor.MsgReplyGetSizes {}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgReplyGetSizes"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxMonitor.MsgRelease {}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgRelease"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxMonitor.MsgDone {}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgDone"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]

instance ToObject (AnyMessageAndAgency (LocalTxSubmission tx err)) where
  toObject :: TracingVerbosity
-> AnyMessageAndAgency (LocalTxSubmission tx err) -> Object
toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxSub.MsgSubmitTx{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgSubmitTx"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxSub.MsgAcceptTx{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgAcceptTx"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxSub.MsgRejectTx{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgRejectTx"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok LocalTxSub.MsgDone{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgDone"
             , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
             ]

instance ToObject (AnyMessageAndAgency (ChainSync blk pt tip)) where
   toObject :: TracingVerbosity
-> AnyMessageAndAgency (ChainSync blk pt tip) -> Object
toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok ChainSync.MsgRequestNext{}) =
     [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgRequestNext"
              , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
              ]
   toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok ChainSync.MsgAwaitReply{}) =
     [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgAwaitReply"
              , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
              ]
   toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok ChainSync.MsgRollForward{}) =
     [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgRollForward"
              , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
              ]
   toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok ChainSync.MsgRollBackward{}) =
     [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgRollBackward"
              , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
              ]
   toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok ChainSync.MsgFindIntersect{}) =
     [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgFindIntersect"
              , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
              ]
   toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok ChainSync.MsgIntersectFound{}) =
     [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgIntersectFound"
              , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
              ]
   toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok ChainSync.MsgIntersectNotFound{}) =
     [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgIntersectNotFound"
              , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
              ]
   toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok ChainSync.MsgDone{}) =
     [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgDone"
              , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
              ]

instance (Show txid, Show tx)
      => ToObject (AnyMessageAndAgency (TxSubmission2 txid tx)) where
  toObject :: TracingVerbosity
-> AnyMessageAndAgency (TxSubmission2 txid tx) -> Object
toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok Message (TxSubmission2 txid tx) st st'
MsgInit) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgInit"
      , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
      ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok (MsgRequestTxs txids)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgRequestTxs"
      , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
      , Key
"txIds" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ [txid1] -> String
forall a. Show a => a -> String
show [txid1]
txids)
      ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok (MsgReplyTxs txs)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgReplyTxs"
      , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
      , Key
"txs" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ [tx1] -> String
forall a. Show a => a -> String
show [tx1]
txs)
      ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok MsgRequestTxIds{}) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgRequestTxIds"
      , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
      ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok (MsgReplyTxIds _)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgReplyTxIds"
      , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
      ]
  toObject TracingVerbosity
_verb (AnyMessageAndAgency PeerHasAgency pr st
stok Message (TxSubmission2 txid tx) st st'
MsgDone) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MsgDone"
      , Key
"agency" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ PeerHasAgency pr st -> String
forall a. Show a => a -> String
show PeerHasAgency pr st
stok)
      ]

instance ToJSON peerAddr => ToJSON (ConnectionId peerAddr) where
  toJSON :: ConnectionId peerAddr -> Value
toJSON ConnectionId { peerAddr
localAddress :: forall addr. ConnectionId addr -> addr
localAddress :: peerAddr
localAddress, peerAddr
remoteAddress :: forall addr. ConnectionId addr -> addr
remoteAddress :: peerAddr
remoteAddress } =
    [Pair] -> Value
Aeson.object [ Key
"localAddress"  Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= peerAddr -> Value
forall a. ToJSON a => a -> Value
toJSON peerAddr
localAddress
                 , Key
"remoteAddress" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= peerAddr -> Value
forall a. ToJSON a => a -> Value
toJSON peerAddr
remoteAddress
                 ]

instance Aeson.ToJSON ConnectionManagerCounters where
  toJSON :: ConnectionManagerCounters -> Value
toJSON ConnectionManagerCounters { Int
fullDuplexConns :: ConnectionManagerCounters -> Int
fullDuplexConns :: Int
fullDuplexConns
                                   , Int
duplexConns :: ConnectionManagerCounters -> Int
duplexConns :: Int
duplexConns
                                   , Int
unidirectionalConns :: ConnectionManagerCounters -> Int
unidirectionalConns :: Int
unidirectionalConns
                                   , Int
inboundConns :: ConnectionManagerCounters -> Int
inboundConns :: Int
inboundConns
                                   , Int
outboundConns :: ConnectionManagerCounters -> Int
outboundConns :: Int
outboundConns
                                   } =
    [Pair] -> Value
Aeson.object [ Key
"fullDuplex"     Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON Int
fullDuplexConns
                 , Key
"duplex"         Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON Int
duplexConns
                 , Key
"unidirectional" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON Int
unidirectionalConns
                 , Key
"inbound"        Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
inboundConns
                 , Key
"outbound"       Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
outboundConns
                 ]

instance ToObject (FetchDecision [Point header]) where
  toObject :: TracingVerbosity -> FetchDecision [Point header] -> Object
toObject TracingVerbosity
_verb (Left FetchDecline
decline) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"FetchDecision declined"
             , Key
"declined" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (FetchDecline -> String
forall a. Show a => a -> String
show FetchDecline
decline))
             ]
  toObject TracingVerbosity
_verb (Right [Point header]
results) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"FetchDecision results"
             , Key
"length" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Int -> String
forall a. Show a => a -> String
show (Int -> String) -> Int -> String
forall a b. (a -> b) -> a -> b
$ [Point header] -> Int
forall a. HasLength a => a -> Int
length [Point header]
results)
             ]

-- TODO: use 'ToJSON' constraints
instance (Show ntnAddr, Show ntcAddr) => ToObject (ND.InitializationTracer ntnAddr ntcAddr) where
  toObject :: TracingVerbosity -> InitializationTracer ntnAddr ntcAddr -> Object
toObject TracingVerbosity
_verb (ND.RunServer NonEmpty ntnAddr
sockAddr) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"RunServer"
    , Key
"socketAddress" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (NonEmpty ntnAddr -> String
forall a. Show a => a -> String
show NonEmpty ntnAddr
sockAddr))
    ]

  toObject TracingVerbosity
_verb (ND.RunLocalServer ntcAddr
localAddress) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"RunLocalServer"
    , Key
"localAddress" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (ntcAddr -> String
forall a. Show a => a -> String
show ntcAddr
localAddress))
    ]
  toObject TracingVerbosity
_verb (ND.UsingSystemdSocket ntcAddr
localAddress) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UsingSystemdSocket"
    , Key
"path" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (ntcAddr -> String) -> ntcAddr -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ntcAddr -> String
forall a. Show a => a -> String
show (ntcAddr -> Text) -> ntcAddr -> Text
forall a b. (a -> b) -> a -> b
$ ntcAddr
localAddress)
    ]

  toObject TracingVerbosity
_verb (ND.CreateSystemdSocketForSnocketPath ntcAddr
localAddress) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"CreateSystemdSocketForSnocketPath"
    , Key
"path" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (ntcAddr -> String) -> ntcAddr -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ntcAddr -> String
forall a. Show a => a -> String
show (ntcAddr -> Text) -> ntcAddr -> Text
forall a b. (a -> b) -> a -> b
$ ntcAddr
localAddress)
    ]
  toObject TracingVerbosity
_verb (ND.CreatedLocalSocket ntcAddr
localAddress) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"CreatedLocalSocket"
    , Key
"path" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (ntcAddr -> String) -> ntcAddr -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ntcAddr -> String
forall a. Show a => a -> String
show (ntcAddr -> Text) -> ntcAddr -> Text
forall a b. (a -> b) -> a -> b
$ ntcAddr
localAddress)
    ]
  toObject TracingVerbosity
_verb (ND.ConfiguringLocalSocket ntcAddr
localAddress FileDescriptor
socket) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConfiguringLocalSocket"
    , Key
"path" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (ntcAddr -> String) -> ntcAddr -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ntcAddr -> String
forall a. Show a => a -> String
show (ntcAddr -> Text) -> ntcAddr -> Text
forall a b. (a -> b) -> a -> b
$ ntcAddr
localAddress)
    , Key
"socket" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (FileDescriptor -> String
forall a. Show a => a -> String
show FileDescriptor
socket))
    ]
  toObject TracingVerbosity
_verb (ND.ListeningLocalSocket ntcAddr
localAddress FileDescriptor
socket) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ListeningLocalSocket"
    , Key
"path" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (ntcAddr -> String) -> ntcAddr -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ntcAddr -> String
forall a. Show a => a -> String
show (ntcAddr -> Text) -> ntcAddr -> Text
forall a b. (a -> b) -> a -> b
$ ntcAddr
localAddress)
    , Key
"socket" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (FileDescriptor -> String
forall a. Show a => a -> String
show FileDescriptor
socket))
    ]
  toObject TracingVerbosity
_verb (ND.LocalSocketUp ntcAddr
localAddress FileDescriptor
fd) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalSocketUp"
    , Key
"path" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (ntcAddr -> String) -> ntcAddr -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. ntcAddr -> String
forall a. Show a => a -> String
show (ntcAddr -> Text) -> ntcAddr -> Text
forall a b. (a -> b) -> a -> b
$ ntcAddr
localAddress)
    , Key
"socket" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (FileDescriptor -> String
forall a. Show a => a -> String
show FileDescriptor
fd))
    ]
  toObject TracingVerbosity
_verb (ND.CreatingServerSocket ntnAddr
socket) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"CreatingServerSocket"
    , Key
"socket" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (ntnAddr -> String
forall a. Show a => a -> String
show ntnAddr
socket))
    ]
  toObject TracingVerbosity
_verb (ND.ListeningServerSocket ntnAddr
socket) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ListeningServerSocket"
    , Key
"socket" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (ntnAddr -> String
forall a. Show a => a -> String
show ntnAddr
socket))
    ]
  toObject TracingVerbosity
_verb (ND.ServerSocketUp ntnAddr
socket) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ServerSocketUp"
    , Key
"socket" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (ntnAddr -> String
forall a. Show a => a -> String
show ntnAddr
socket))
    ]
  toObject TracingVerbosity
_verb (ND.ConfiguringServerSocket ntnAddr
socket) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ConfiguringServerSocket"
    , Key
"socket" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (ntnAddr -> String
forall a. Show a => a -> String
show ntnAddr
socket))
    ]
  toObject TracingVerbosity
_verb (ND.UnsupportedLocalSystemdSocket ntnAddr
path) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UnsupportedLocalSystemdSocket"
    , Key
"path" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (ntnAddr -> String
forall a. Show a => a -> String
show ntnAddr
path))
    ]
  toObject TracingVerbosity
_verb InitializationTracer ntnAddr ntcAddr
ND.UnsupportedReadySocketCase = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UnsupportedReadySocketCase"
    ]
  toObject TracingVerbosity
_verb (ND.DiffusionErrored SomeException
exception) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DiffusionErrored"
    , Key
"path" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (SomeException -> String
forall a. Show a => a -> String
show SomeException
exception))
    ]

instance ToObject (NtC.HandshakeTr LocalAddress NodeToClientVersion) where
  toObject :: TracingVerbosity
-> HandshakeTr LocalAddress NodeToClientVersion -> Object
toObject TracingVerbosity
_verb (WithMuxBearer ConnectionId LocalAddress
b TraceSendRecv (Handshake NodeToClientVersion Term)
ev) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalHandshakeTrace"
             , Key
"bearer" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId LocalAddress -> String
forall a. Show a => a -> String
show ConnectionId LocalAddress
b
             , Key
"event" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TraceSendRecv (Handshake NodeToClientVersion Term) -> String
forall a. Show a => a -> String
show TraceSendRecv (Handshake NodeToClientVersion Term)
ev ]


instance ToObject (NtN.HandshakeTr RemoteAddress NodeToNodeVersion) where
  toObject :: TracingVerbosity
-> HandshakeTr RemoteAddress NodeToNodeVersion -> Object
toObject TracingVerbosity
_verb (WithMuxBearer ConnectionId RemoteAddress
b TraceSendRecv (Handshake NodeToNodeVersion Term)
ev) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"HandshakeTrace"
             , Key
"bearer" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ConnectionId RemoteAddress -> String
forall a. Show a => a -> String
show ConnectionId RemoteAddress
b
             , Key
"event" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TraceSendRecv (Handshake NodeToNodeVersion Term) -> String
forall a. Show a => a -> String
show TraceSendRecv (Handshake NodeToNodeVersion Term)
ev ]

instance ToJSON LocalAddress where
    toJSON :: LocalAddress -> Value
toJSON (LocalAddress String
path) = Text -> Value
String (String -> Text
pack String
path)

instance Aeson.ToJSONKey LocalAddress where

instance ToObject NtN.AcceptConnectionsPolicyTrace where
  toObject :: TracingVerbosity -> AcceptConnectionsPolicyTrace -> Object
toObject TracingVerbosity
_verb (NtN.ServerTraceAcceptConnectionRateLimiting DiffTime
delay Int
numOfConnections) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ServerTraceAcceptConnectionRateLimiting"
             , Key
"delay" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DiffTime -> String
forall a. Show a => a -> String
show DiffTime
delay
             , Key
"numberOfConnection" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> String
forall a. Show a => a -> String
show Int
numOfConnections
             ]
  toObject TracingVerbosity
_verb (NtN.ServerTraceAcceptConnectionHardLimit SizeInBytes
softLimit) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ServerTraceAcceptConnectionHardLimit"
             , Key
"softLimit" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SizeInBytes -> String
forall a. Show a => a -> String
show SizeInBytes
softLimit
             ]
  toObject TracingVerbosity
_verb (NtN.ServerTraceAcceptConnectionResume Int
numOfConnections) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ServerTraceAcceptConnectionResume"
             , Key
"numberOfConnection" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> String
forall a. Show a => a -> String
show Int
numOfConnections
             ]


instance ConvertRawHash blk
      => ToObject (Point blk) where
  toObject :: TracingVerbosity -> Point blk -> Object
toObject TracingVerbosity
_verb Point blk
GenesisPoint =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"GenesisPoint" ]
  toObject TracingVerbosity
verb (BlockPoint SlotNo
slot HeaderHash blk
h) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"BlockPoint"
      , Key
"slot" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word64 -> Value
forall a. ToJSON a => a -> Value
toJSON (SlotNo -> Word64
unSlotNo SlotNo
slot)
      , Key
"headerHash" Key -> Text -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Proxy blk -> TracingVerbosity -> HeaderHash blk -> Text
forall blk (proxy :: * -> *).
ConvertRawHash blk =>
proxy blk -> TracingVerbosity -> HeaderHash blk -> Text
renderHeaderHashForVerbosity (Proxy blk
forall k (t :: k). Proxy t
Proxy @blk) TracingVerbosity
verb HeaderHash blk
h
      ]


instance ToObject SlotNo where
  toObject :: TracingVerbosity -> SlotNo -> Object
toObject TracingVerbosity
_verb SlotNo
slot =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"SlotNo"
             , Key
"slot" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word64 -> Value
forall a. ToJSON a => a -> Value
toJSON (SlotNo -> Word64
unSlotNo SlotNo
slot) ]

instance (HasHeader header, ConvertRawHash header)
  => ToObject (TraceFetchClientState header) where
  toObject :: TracingVerbosity -> TraceFetchClientState header -> Object
toObject TracingVerbosity
_verb BlockFetch.AddedFetchRequest {} =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"AddedFetchRequest" ]
  toObject TracingVerbosity
_verb BlockFetch.AcknowledgedFetchRequest {} =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"AcknowledgedFetchRequest" ]
  toObject TracingVerbosity
_verb (BlockFetch.SendFetchRequest AnchoredFragment header
af) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"SendFetchRequest"
             , Key
"head" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String ((HeaderHash header -> Text) -> ChainHash header -> Text
forall blk. (HeaderHash blk -> Text) -> ChainHash blk -> Text
renderChainHash
                                  (Proxy header -> HeaderHash header -> Text
forall blk (proxy :: * -> *).
ConvertRawHash blk =>
proxy blk -> HeaderHash blk -> Text
renderHeaderHash (Proxy header
forall k (t :: k). Proxy t
Proxy @header))
                                  (AnchoredFragment header -> ChainHash header
forall block.
HasHeader block =>
AnchoredFragment block -> ChainHash block
AF.headHash AnchoredFragment header
af))
             , Key
"length" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (AnchoredFragment header -> Int
fragmentLength AnchoredFragment header
af)]
   where
     -- NOTE: this ignores the Byron era with its EBB complication:
     -- the length would be underestimated by 1, if the AF is anchored
     -- at the epoch boundary.
     fragmentLength :: AF.AnchoredFragment header -> Int
     fragmentLength :: AnchoredFragment header -> Int
fragmentLength AnchoredFragment header
f = Word64 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> Int) -> (BlockNo -> Word64) -> BlockNo -> Int
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. BlockNo -> Word64
unBlockNo (BlockNo -> Int) -> BlockNo -> Int
forall a b. (a -> b) -> a -> b
$
        case (AnchoredFragment header
f, AnchoredFragment header
f) of
          (AS.Empty{}, AS.Empty{}) -> BlockNo
0
          (header
firstHdr AS.:< AnchoredFragment header
_, AnchoredFragment header
_ AS.:> header
lastHdr) ->
            header -> BlockNo
forall b. HasHeader b => b -> BlockNo
blockNo header
lastHdr BlockNo -> BlockNo -> BlockNo
forall a. Num a => a -> a -> a
- header -> BlockNo
forall b. HasHeader b => b -> BlockNo
blockNo header
firstHdr BlockNo -> BlockNo -> BlockNo
forall a. Num a => a -> a -> a
+ BlockNo
1
  toObject TracingVerbosity
_verb (BlockFetch.CompletedBlockFetch Point header
pt PeerFetchInFlight header
_ PeerFetchInFlightLimits
_ PeerFetchStatus header
_ NominalDiffTime
delay SizeInBytes
blockSize) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind"  Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"CompletedBlockFetch"
             , Key
"delay" Key -> Double -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (NominalDiffTime -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac NominalDiffTime
delay :: Double)
             , Key
"size"  Key -> SizeInBytes -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SizeInBytes
blockSize
             , Key
"block" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String
               (case Point header
pt of
                  Point header
GenesisPoint -> Text
"Genesis"
                  BlockPoint SlotNo
_ HeaderHash header
h -> Proxy header -> HeaderHash header -> Text
forall blk (proxy :: * -> *).
ConvertRawHash blk =>
proxy blk -> HeaderHash blk -> Text
renderHeaderHash (Proxy header
forall k (t :: k). Proxy t
Proxy @header) HeaderHash header
h)
             ]
  toObject TracingVerbosity
_verb BlockFetch.CompletedFetchBatch {} =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"CompletedFetchBatch" ]
  toObject TracingVerbosity
_verb BlockFetch.StartedFetchBatch {} =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"StartedFetchBatch" ]
  toObject TracingVerbosity
_verb BlockFetch.RejectedFetchBatch {} =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"RejectedFetchBatch" ]
  toObject TracingVerbosity
_verb (BlockFetch.ClientTerminating Int
outstanding) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ClientTerminating"
             , Key
"outstanding" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
outstanding
             ]


instance (ToObject peer)
      => ToObject [TraceLabelPeer peer (FetchDecision [Point header])] where
  toObject :: TracingVerbosity
-> [TraceLabelPeer peer (FetchDecision [Point header])] -> Object
toObject TracingVerbosity
MinimalVerbosity [TraceLabelPeer peer (FetchDecision [Point header])]
_ = Object
forall a. Monoid a => a
mempty
  toObject TracingVerbosity
_ [] = Object
forall a. Monoid a => a
mempty
  toObject TracingVerbosity
_ [TraceLabelPeer peer (FetchDecision [Point header])]
xs = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind"  Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PeersFetch"
    , Key
"peers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Object] -> Value
forall a. ToJSON a => a -> Value
toJSON
      (([Object]
 -> TraceLabelPeer peer (FetchDecision [Point header]) -> [Object])
-> [Object]
-> [TraceLabelPeer peer (FetchDecision [Point header])]
-> [Object]
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\[Object]
acc TraceLabelPeer peer (FetchDecision [Point header])
x -> TracingVerbosity
-> TraceLabelPeer peer (FetchDecision [Point header]) -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
MaximalVerbosity TraceLabelPeer peer (FetchDecision [Point header])
x Object -> [Object] -> [Object]
forall a. a -> [a] -> [a]
: [Object]
acc) [] [TraceLabelPeer peer (FetchDecision [Point header])]
xs) ]

instance (ToObject peer, ToObject a) => ToObject (TraceLabelPeer peer a) where
  toObject :: TracingVerbosity -> TraceLabelPeer peer a -> Object
toObject TracingVerbosity
verb (TraceLabelPeer peer
peerid a
a) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"peer" Key -> Object -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TracingVerbosity -> peer -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb peer
peerid ] Object -> Object -> Object
forall a. Semigroup a => a -> a -> a
<> TracingVerbosity -> a -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb a
a


instance ToObject (AnyMessageAndAgency ps)
      => ToObject (TraceSendRecv ps) where
  toObject :: TracingVerbosity -> TraceSendRecv ps -> Object
toObject TracingVerbosity
verb (TraceSendMsg AnyMessageAndAgency ps
m) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Send" , Key
"msg" Key -> Object -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TracingVerbosity -> AnyMessageAndAgency ps -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb AnyMessageAndAgency ps
m ]
  toObject TracingVerbosity
verb (TraceRecvMsg AnyMessageAndAgency ps
m) = [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
    [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"Recv" , Key
"msg" Key -> Object -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TracingVerbosity -> AnyMessageAndAgency ps -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb AnyMessageAndAgency ps
m ]


instance ToObject (TraceTxSubmissionInbound txid tx) where
  toObject :: TracingVerbosity -> TraceTxSubmissionInbound txid tx -> Object
toObject TracingVerbosity
_verb (TraceTxSubmissionCollected Int
count) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TxSubmissionCollected"
      , Key
"count" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON Int
count
      ]
  toObject TracingVerbosity
_verb (TraceTxSubmissionProcessed ProcessedTxCount
processed) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TxSubmissionProcessed"
      , Key
"accepted" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (ProcessedTxCount -> Int
ptxcAccepted ProcessedTxCount
processed)
      , Key
"rejected" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON (ProcessedTxCount -> Int
ptxcRejected ProcessedTxCount
processed)
      ]
  toObject TracingVerbosity
_verb TraceTxSubmissionInbound txid tx
TraceTxInboundTerminated =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TxInboundTerminated"
      ]
  toObject TracingVerbosity
_verb (TraceTxInboundCanRequestMoreTxs Int
count) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TxInboundCanRequestMoreTxs"
      , Key
"count" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON Int
count
      ]
  toObject TracingVerbosity
_verb (TraceTxInboundCannotRequestMoreTxs Int
count) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TxInboundCannotRequestMoreTxs"
      , Key
"count" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Value
forall a. ToJSON a => a -> Value
toJSON Int
count
      ]


instance Aeson.ToJSONKey SockAddr where

instance Aeson.ToJSON SockAddr where
    toJSON :: RemoteAddress -> Value
toJSON (SockAddrInet PortNumber
port SizeInBytes
addr) =
        let ip :: IPv4
ip = SizeInBytes -> IPv4
IP.fromHostAddress SizeInBytes
addr in
        [Pair] -> Value
Aeson.object [ Key
"address" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= IPv4 -> Value
forall a. ToJSON a => a -> Value
toJSON IPv4
ip
                     , Key
"port" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PortNumber -> String
forall a. Show a => a -> String
show PortNumber
port
                     ]
    toJSON (SockAddrInet6 PortNumber
port SizeInBytes
_ HostAddress6
addr SizeInBytes
_) =
        let ip :: IPv6
ip = HostAddress6 -> IPv6
IP.fromHostAddress6 HostAddress6
addr in
        [Pair] -> Value
Aeson.object [ Key
"address" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= IPv6 -> Value
forall a. ToJSON a => a -> Value
toJSON IPv6
ip
                     , Key
"port" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PortNumber -> String
forall a. Show a => a -> String
show PortNumber
port
                     ]
    toJSON (SockAddrUnix String
path) =
        [Pair] -> Value
Aeson.object [ Key
"socketPath" Key -> String -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= String -> String
forall a. Show a => a -> String
show String
path ]

-- TODO: use the json encoding of transactions
instance (Show txid, Show tx)
      => ToObject (TraceTxSubmissionOutbound txid tx) where
  toObject :: TracingVerbosity -> TraceTxSubmissionOutbound txid tx -> Object
toObject TracingVerbosity
MaximalVerbosity (TraceTxSubmissionOutboundRecvMsgRequestTxs [txid]
txids) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TxSubmissionOutboundRecvMsgRequestTxs"
      , Key
"txIds" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ [txid] -> String
forall a. Show a => a -> String
show [txid]
txids)
      ]
  toObject TracingVerbosity
_verb (TraceTxSubmissionOutboundRecvMsgRequestTxs [txid]
_txids) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TxSubmissionOutboundRecvMsgRequestTxs"
      ]
  toObject TracingVerbosity
MaximalVerbosity (TraceTxSubmissionOutboundSendMsgReplyTxs [tx]
txs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TxSubmissionOutboundSendMsgReplyTxs"
      , Key
"txs" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ [tx] -> String
forall a. Show a => a -> String
show [tx]
txs)
      ]
  toObject TracingVerbosity
_verb (TraceTxSubmissionOutboundSendMsgReplyTxs [tx]
_txs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TxSubmissionOutboundSendMsgReplyTxs"
      ]
  toObject TracingVerbosity
_verb (TraceControlMessage ControlMessage
controlMessage) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ControlMessage"
      , Key
"controlMessage" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ ControlMessage -> String
forall a. Show a => a -> String
show ControlMessage
controlMessage)
      ]


instance Show remotePeer => ToObject (TraceKeepAliveClient remotePeer) where
  toObject :: TracingVerbosity -> TraceKeepAliveClient remotePeer -> Object
toObject TracingVerbosity
_verb (AddSample remotePeer
peer DiffTime
rtt PeerGSV
pgsv) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"KeepAliveClient AddSample"
      , Key
"address" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= remotePeer -> String
forall a. Show a => a -> String
show remotePeer
peer
      , Key
"rtt" Key -> DiffTime -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DiffTime
rtt
      , Key
"sampleTime" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Double -> String
forall a. Show a => a -> String
show (Time -> Double
dTime (Time -> Double) -> Time -> Double
forall a b. (a -> b) -> a -> b
$ PeerGSV -> Time
sampleTime PeerGSV
pgsv)
      , Key
"outboundG" Key -> Double -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (DiffTime -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac (DiffTime -> Double) -> DiffTime -> Double
forall a b. (a -> b) -> a -> b
$ GSV -> DiffTime
gGSV (PeerGSV -> GSV
outboundGSV PeerGSV
pgsv) :: Double)
      , Key
"inboundG" Key -> Double -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (DiffTime -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac (DiffTime -> Double) -> DiffTime -> Double
forall a b. (a -> b) -> a -> b
$ GSV -> DiffTime
gGSV (PeerGSV -> GSV
inboundGSV PeerGSV
pgsv) :: Double)
      ]
    where
      gGSV :: GSV -> DiffTime
      gGSV :: GSV -> DiffTime
gGSV (GSV DiffTime
g SizeInBytes -> DiffTime
_ Distribution DiffTime
_) = DiffTime
g

      dTime :: Time -> Double
      dTime :: Time -> Double
dTime (Time DiffTime
d) = DiffTime -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac DiffTime
d


instance ToObject TraceLedgerPeers where
  toObject :: TracingVerbosity -> TraceLedgerPeers -> Object
toObject TracingVerbosity
_verb (PickedPeer RelayAccessPoint
addr AccPoolStake
_ackStake PoolStake
stake) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PickedPeer"
      , Key
"address" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RelayAccessPoint -> String
forall a. Show a => a -> String
show RelayAccessPoint
addr
      , Key
"relativeStake" Key -> Double -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Rational -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac (PoolStake -> Rational
unPoolStake PoolStake
stake) :: Double)
      ]
  toObject TracingVerbosity
_verb (PickedPeers (NumberOfPeers Word16
n) [RelayAccessPoint]
addrs) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PickedPeers"
      , Key
"desiredCount" Key -> Word16 -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word16
n
      , Key
"count" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RelayAccessPoint] -> Int
forall a. HasLength a => a -> Int
length [RelayAccessPoint]
addrs
      , Key
"addresses" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RelayAccessPoint] -> String
forall a. Show a => a -> String
show [RelayAccessPoint]
addrs
      ]
  toObject TracingVerbosity
_verb (FetchingNewLedgerState Int
cnt) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"FetchingNewLedgerState"
      , Key
"numberOfPools" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
cnt
      ]
  toObject TracingVerbosity
_verb TraceLedgerPeers
DisabledLedgerPeers =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DisabledLedgerPeers"
      ]
  toObject TracingVerbosity
_verb (TraceUseLedgerAfter UseLedgerAfter
ula) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UseLedgerAfter"
      , Key
"useLedgerAfter" Key -> UseLedger -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= UseLedgerAfter -> UseLedger
UseLedger UseLedgerAfter
ula
      ]
  toObject TracingVerbosity
_verb TraceLedgerPeers
WaitingOnRequest =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WaitingOnRequest"
      ]
  toObject TracingVerbosity
_verb (RequestForPeers (NumberOfPeers Word16
np)) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"RequestForPeers"
      , Key
"numberOfPeers" Key -> Word16 -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word16
np
      ]
  toObject TracingVerbosity
_verb (ReusingLedgerState Int
cnt DiffTime
age) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ReusingLedgerState"
      , Key
"numberOfPools" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
cnt
      , Key
"ledgerStateAge" Key -> DiffTime -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DiffTime
age
      ]
  toObject TracingVerbosity
_verb TraceLedgerPeers
FallingBackToBootstrapPeers =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat
      [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"FallingBackToBootstrapPeers"
      ]


instance Show addr => ToObject (WithAddr addr ErrorPolicyTrace) where
  toObject :: TracingVerbosity -> WithAddr addr ErrorPolicyTrace -> Object
toObject TracingVerbosity
_verb (WithAddr addr
addr ErrorPolicyTrace
ev) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ErrorPolicyTrace"
             , Key
"address" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= addr -> String
forall a. Show a => a -> String
show addr
addr
             , Key
"event" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ErrorPolicyTrace -> String
forall a. Show a => a -> String
show ErrorPolicyTrace
ev ]


instance ToObject (WithIPList (SubscriptionTrace SockAddr)) where
  toObject :: TracingVerbosity
-> WithIPList (SubscriptionTrace RemoteAddress) -> Object
toObject TracingVerbosity
_verb (WithIPList LocalAddresses RemoteAddress
localAddresses [RemoteAddress]
dests SubscriptionTrace RemoteAddress
ev) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"WithIPList SubscriptionTrace"
             , Key
"localAddresses" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= LocalAddresses RemoteAddress -> String
forall a. Show a => a -> String
show LocalAddresses RemoteAddress
localAddresses
             , Key
"dests" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RemoteAddress] -> String
forall a. Show a => a -> String
show [RemoteAddress]
dests
             , Key
"event" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SubscriptionTrace RemoteAddress -> String
forall a. Show a => a -> String
show SubscriptionTrace RemoteAddress
ev ]


instance ToObject (WithDomainName DnsTrace) where
  toObject :: TracingVerbosity -> WithDomainName DnsTrace -> Object
toObject TracingVerbosity
_verb (WithDomainName Domain
dom DnsTrace
ev) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DnsTrace"
             , Key
"domain" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Domain -> String
forall a. Show a => a -> String
show Domain
dom
             , Key
"event" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DnsTrace -> String
forall a. Show a => a -> String
show DnsTrace
ev ]


instance ToObject (WithDomainName (SubscriptionTrace SockAddr)) where
  toObject :: TracingVerbosity
-> WithDomainName (SubscriptionTrace RemoteAddress) -> Object
toObject TracingVerbosity
_verb (WithDomainName Domain
dom SubscriptionTrace RemoteAddress
ev) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"SubscriptionTrace"
             , Key
"domain" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Domain -> String
forall a. Show a => a -> String
show Domain
dom
             , Key
"event" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SubscriptionTrace RemoteAddress -> String
forall a. Show a => a -> String
show SubscriptionTrace RemoteAddress
ev ]


instance ToObject peer => ToObject (WithMuxBearer peer MuxTrace) where
  toObject :: TracingVerbosity -> WithMuxBearer peer MuxTrace -> Object
toObject TracingVerbosity
verb (WithMuxBearer peer
b MuxTrace
ev) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"MuxTrace"
             , Key
"bearer" Key -> Object -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= TracingVerbosity -> peer -> Object
forall a. ToObject a => TracingVerbosity -> a -> Object
toObject TracingVerbosity
verb peer
b
             , Key
"event" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= MuxTrace -> String
forall a. Show a => a -> String
show MuxTrace
ev ]

instance Aeson.ToJSONKey RelayAccessPoint where

instance Show exception => ToObject (TraceLocalRootPeers RemoteAddress exception) where
  toObject :: TracingVerbosity
-> TraceLocalRootPeers RemoteAddress exception -> Object
toObject TracingVerbosity
_verb (TraceLocalRootDomains [(Int, Map RelayAccessPoint PeerAdvertise)]
groups) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootDomains"
             , Key
"localRootDomains" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(Int, Map RelayAccessPoint PeerAdvertise)] -> Value
forall a. ToJSON a => a -> Value
toJSON [(Int, Map RelayAccessPoint PeerAdvertise)]
groups
             ]
  toObject TracingVerbosity
_verb (TraceLocalRootWaiting DomainAccessPoint
d DiffTime
dt) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootWaiting"
             , Key
"domainAddress" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DomainAccessPoint -> Value
forall a. ToJSON a => a -> Value
toJSON DomainAccessPoint
d
             , Key
"diffTime" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DiffTime -> String
forall a. Show a => a -> String
show DiffTime
dt
             ]
  toObject TracingVerbosity
_verb (TraceLocalRootResult DomainAccessPoint
d [(IP, SizeInBytes)]
res) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootResult"
             , Key
"domainAddress" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DomainAccessPoint -> Value
forall a. ToJSON a => a -> Value
toJSON DomainAccessPoint
d
             , Key
"result" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(IP, SizeInBytes)] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList [(IP, SizeInBytes)]
res
             ]
  toObject TracingVerbosity
_verb (TraceLocalRootGroups Seq (Int, Map RemoteAddress PeerAdvertise)
groups) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootGroups"
             , Key
"localRootGroups" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Seq (Int, Map RemoteAddress PeerAdvertise) -> Value
forall a. ToJSON a => a -> Value
toJSON Seq (Int, Map RemoteAddress PeerAdvertise)
groups
             ]
  toObject TracingVerbosity
_verb (TraceLocalRootFailure DomainAccessPoint
d DNSorIOError exception
dexception) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootFailure"
             , Key
"domainAddress" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DomainAccessPoint -> Value
forall a. ToJSON a => a -> Value
toJSON DomainAccessPoint
d
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DNSorIOError exception -> String
forall a. Show a => a -> String
show DNSorIOError exception
dexception
             ]
  toObject TracingVerbosity
_verb (TraceLocalRootError DomainAccessPoint
d SomeException
dexception) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootError"
             , Key
"domainAddress" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DomainAccessPoint -> Value
forall a. ToJSON a => a -> Value
toJSON DomainAccessPoint
d
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
dexception
             ]

instance ToJSON IP where
  toJSON :: IP -> Value
toJSON IP
ip = Text -> Value
String (String -> Text
pack (String -> Text) -> (IP -> String) -> IP -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. IP -> String
forall a. Show a => a -> String
show (IP -> Text) -> IP -> Text
forall a b. (a -> b) -> a -> b
$ IP
ip)

instance ToObject TracePublicRootPeers where
  toObject :: TracingVerbosity -> TracePublicRootPeers -> Object
toObject TracingVerbosity
_verb (TracePublicRootRelayAccessPoint [RelayAccessPoint]
relays) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PublicRootRelayAddresses"
             , Key
"relayAddresses" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RelayAccessPoint] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList [RelayAccessPoint]
relays
             ]
  toObject TracingVerbosity
_verb (TracePublicRootDomains [DomainAccessPoint]
domains) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PublicRootDomains"
             , Key
"domainAddresses" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [DomainAccessPoint] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList [DomainAccessPoint]
domains
             ]
  toObject TracingVerbosity
_verb (TracePublicRootResult Domain
b [(IP, SizeInBytes)]
res) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PublicRootResult"
             , Key
"domain" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Domain -> String
forall a. Show a => a -> String
show Domain
b
             , Key
"result" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(IP, SizeInBytes)] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList [(IP, SizeInBytes)]
res
             ]
  toObject TracingVerbosity
_verb (TracePublicRootFailure Domain
b DNSError
d) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PublicRootFailure"
             , Key
"domain" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Domain -> String
forall a. Show a => a -> String
show Domain
b
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DNSError -> String
forall a. Show a => a -> String
show DNSError
d
             ]

instance ToJSON PeerStatus where
  toJSON :: PeerStatus -> Value
toJSON = Text -> Value
String (Text -> Value) -> (PeerStatus -> Text) -> PeerStatus -> Value
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> Text
pack (String -> Text) -> (PeerStatus -> String) -> PeerStatus -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. PeerStatus -> String
forall a. Show a => a -> String
show

instance (Aeson.ToJSONKey peerAddr, ToJSON peerAddr, Ord peerAddr, Show peerAddr)
  => ToJSON (LocalRootPeers peerAddr) where
  toJSON :: LocalRootPeers peerAddr -> Value
toJSON LocalRootPeers peerAddr
lrp =
    [Pair] -> Value
Aeson.object [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootPeers"
                 , Key
"groups" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(Int, Map peerAddr PeerAdvertise)] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList (LocalRootPeers peerAddr -> [(Int, Map peerAddr PeerAdvertise)]
forall peeraddr.
Ord peeraddr =>
LocalRootPeers peeraddr -> [(Int, Map peeraddr PeerAdvertise)]
LocalRootPeers.toGroups LocalRootPeers peerAddr
lrp)
                 ]

instance ToJSON PeerSelectionTargets where
  toJSON :: PeerSelectionTargets -> Value
toJSON (PeerSelectionTargets
            Int
nRootPeers
            Int
nKnownPeers
            Int
nEstablishedPeers
            Int
nActivePeers
         ) =
    [Pair] -> Value
Aeson.object [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PeerSelectionTargets"
                 , Key
"targetRootPeers" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
nRootPeers
                 , Key
"targetKnownPeers" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
nKnownPeers
                 , Key
"targetEstablishedPeers" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
nEstablishedPeers
                 , Key
"targetActivePeers" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
nActivePeers
                 ]

instance ToObject (TracePeerSelection SockAddr) where
  toObject :: TracingVerbosity -> TracePeerSelection RemoteAddress -> Object
toObject TracingVerbosity
_verb (TraceLocalRootPeersChanged LocalRootPeers RemoteAddress
lrp LocalRootPeers RemoteAddress
lrp') =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"LocalRootPeersChanged"
             , Key
"previous" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= LocalRootPeers RemoteAddress -> Value
forall a. ToJSON a => a -> Value
toJSON LocalRootPeers RemoteAddress
lrp
             , Key
"current" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= LocalRootPeers RemoteAddress -> Value
forall a. ToJSON a => a -> Value
toJSON LocalRootPeers RemoteAddress
lrp'
             ]
  toObject TracingVerbosity
_verb (TraceTargetsChanged PeerSelectionTargets
pst PeerSelectionTargets
pst') =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"TargetsChanged"
             , Key
"previous" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PeerSelectionTargets -> Value
forall a. ToJSON a => a -> Value
toJSON PeerSelectionTargets
pst
             , Key
"current" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= PeerSelectionTargets -> Value
forall a. ToJSON a => a -> Value
toJSON PeerSelectionTargets
pst'
             ]
  toObject TracingVerbosity
_verb (TracePublicRootsRequest Int
tRootPeers Int
nRootPeers) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PublicRootsRequest"
             , Key
"targetNumberOfRootPeers" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tRootPeers
             , Key
"numberOfRootPeers" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
nRootPeers
             ]
  toObject TracingVerbosity
_verb (TracePublicRootsResults Set RemoteAddress
res Int
group DiffTime
dt) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PublicRootsResults"
             , Key
"result" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RemoteAddress] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList (Set RemoteAddress -> [RemoteAddress]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set RemoteAddress
res)
             , Key
"group" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
group
             , Key
"diffTime" Key -> DiffTime -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DiffTime
dt
             ]
  toObject TracingVerbosity
_verb (TracePublicRootsFailure SomeException
err Int
group DiffTime
dt) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PublicRootsFailure"
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
err
             , Key
"group" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
group
             , Key
"diffTime" Key -> DiffTime -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DiffTime
dt
             ]
  toObject TracingVerbosity
_verb (TraceGossipRequests Int
targetKnown Int
actualKnown Set RemoteAddress
aps Set RemoteAddress
sps) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"GossipRequests"
             , Key
"targetKnown" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
targetKnown
             , Key
"actualKnown" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
actualKnown
             , Key
"availablePeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RemoteAddress] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList (Set RemoteAddress -> [RemoteAddress]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set RemoteAddress
aps)
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RemoteAddress] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList (Set RemoteAddress -> [RemoteAddress]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set RemoteAddress
sps)
             ]
  toObject TracingVerbosity
_verb (TraceGossipResults [(RemoteAddress, Either SomeException [RemoteAddress])]
res) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"GossipResults"
             , Key
"result" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(RemoteAddress, Either String [RemoteAddress])] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList (((RemoteAddress, Either SomeException [RemoteAddress])
 -> (RemoteAddress, Either String [RemoteAddress]))
-> [(RemoteAddress, Either SomeException [RemoteAddress])]
-> [(RemoteAddress, Either String [RemoteAddress])]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
map ( (SomeException -> String)
-> ([RemoteAddress] -> [RemoteAddress])
-> Either SomeException [RemoteAddress]
-> Either String [RemoteAddress]
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap SomeException -> String
forall a. Show a => a -> String
show [RemoteAddress] -> [RemoteAddress]
forall a. a -> a
id (Either SomeException [RemoteAddress]
 -> Either String [RemoteAddress])
-> (RemoteAddress, Either SomeException [RemoteAddress])
-> (RemoteAddress, Either String [RemoteAddress])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ) [(RemoteAddress, Either SomeException [RemoteAddress])]
res)
             ]
  toObject TracingVerbosity
_verb (TraceForgetColdPeers Int
targetKnown Int
actualKnown Set RemoteAddress
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ForgeColdPeers"
             , Key
"targetKnown" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
targetKnown
             , Key
"actualKnown" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
actualKnown
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RemoteAddress] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList (Set RemoteAddress -> [RemoteAddress]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set RemoteAddress
sp)
             ]
  toObject TracingVerbosity
_verb (TracePromoteColdPeers Int
targetKnown Int
actualKnown Set RemoteAddress
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteColdPeers"
             , Key
"targetEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
targetKnown
             , Key
"actualEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
actualKnown
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RemoteAddress] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList (Set RemoteAddress -> [RemoteAddress]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set RemoteAddress
sp)
             ]
  toObject TracingVerbosity
_verb (TracePromoteColdLocalPeers Int
tLocalEst Int
aLocalEst Set RemoteAddress
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteColdLocalPeers"
             , Key
"targetLocalEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tLocalEst
             , Key
"actualLocalEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aLocalEst
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RemoteAddress] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList (Set RemoteAddress -> [RemoteAddress]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set RemoteAddress
sp)
             ]
  toObject TracingVerbosity
_verb (TracePromoteColdFailed Int
tEst Int
aEst RemoteAddress
p DiffTime
d SomeException
err) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteColdFailed"
             , Key
"targetEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tEst
             , Key
"actualEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aEst
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RemoteAddress -> Value
forall a. ToJSON a => a -> Value
toJSON RemoteAddress
p
             , Key
"delay" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DiffTime -> Value
forall a. ToJSON a => a -> Value
toJSON DiffTime
d
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
err
             ]
  toObject TracingVerbosity
_verb (TracePromoteColdDone Int
tEst Int
aEst RemoteAddress
p) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteColdDone"
             , Key
"targetEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tEst
             , Key
"actualEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aEst
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RemoteAddress -> Value
forall a. ToJSON a => a -> Value
toJSON RemoteAddress
p
             ]
  toObject TracingVerbosity
_verb (TracePromoteWarmPeers Int
tActive Int
aActive Set RemoteAddress
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteWarmPeers"
             , Key
"targetActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tActive
             , Key
"actualActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aActive
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RemoteAddress] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList (Set RemoteAddress -> [RemoteAddress]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set RemoteAddress
sp)
             ]
  toObject TracingVerbosity
_verb (TracePromoteWarmLocalPeers [(Int, Int)]
taa Set RemoteAddress
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteWarmLocalPeers"
             , Key
"targetActualActive" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(Int, Int)] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList [(Int, Int)]
taa
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RemoteAddress] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList (Set RemoteAddress -> [RemoteAddress]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set RemoteAddress
sp)
             ]
  toObject TracingVerbosity
_verb (TracePromoteWarmFailed Int
tActive Int
aActive RemoteAddress
p SomeException
err) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteWarmFailed"
             , Key
"targetActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tActive
             , Key
"actualActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aActive
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RemoteAddress -> Value
forall a. ToJSON a => a -> Value
toJSON RemoteAddress
p
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
err
             ]
  toObject TracingVerbosity
_verb (TracePromoteWarmDone Int
tActive Int
aActive RemoteAddress
p) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteWarmDone"
             , Key
"targetActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tActive
             , Key
"actualActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aActive
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RemoteAddress -> Value
forall a. ToJSON a => a -> Value
toJSON RemoteAddress
p
             ]
  toObject TracingVerbosity
_verb (TracePromoteWarmAborted Int
tActive Int
aActive RemoteAddress
p) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"PromoteWarmAborted"
             , Key
"targetActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tActive
             , Key
"actualActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aActive
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RemoteAddress -> Value
forall a. ToJSON a => a -> Value
toJSON RemoteAddress
p
             ]
  toObject TracingVerbosity
_verb (TraceDemoteWarmPeers Int
tEst Int
aEst Set RemoteAddress
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteWarmPeers"
             , Key
"targetEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tEst
             , Key
"actualEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aEst
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RemoteAddress] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList (Set RemoteAddress -> [RemoteAddress]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set RemoteAddress
sp)
             ]
  toObject TracingVerbosity
_verb (TraceDemoteWarmFailed Int
tEst Int
aEst RemoteAddress
p SomeException
err) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteWarmFailed"
             , Key
"targetEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tEst
             , Key
"actualEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aEst
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RemoteAddress -> Value
forall a. ToJSON a => a -> Value
toJSON RemoteAddress
p
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
err
             ]
  toObject TracingVerbosity
_verb (TraceDemoteWarmDone Int
tEst Int
aEst RemoteAddress
p) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteWarmDone"
             , Key
"targetEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tEst
             , Key
"actualEstablished" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aEst
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RemoteAddress -> Value
forall a. ToJSON a => a -> Value
toJSON RemoteAddress
p
             ]
  toObject TracingVerbosity
_verb (TraceDemoteHotPeers Int
tActive Int
aActive Set RemoteAddress
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteHotPeers"
             , Key
"targetActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tActive
             , Key
"actualActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aActive
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RemoteAddress] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList (Set RemoteAddress -> [RemoteAddress]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set RemoteAddress
sp)
             ]
  toObject TracingVerbosity
_verb (TraceDemoteLocalHotPeers [(Int, Int)]
taa Set RemoteAddress
sp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteLocalHotPeers"
             , Key
"targetActualActive" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(Int, Int)] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList [(Int, Int)]
taa
             , Key
"selectedPeers" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [RemoteAddress] -> Value
forall a. ToJSON a => [a] -> Value
Aeson.toJSONList (Set RemoteAddress -> [RemoteAddress]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Set RemoteAddress
sp)
             ]
  toObject TracingVerbosity
_verb (TraceDemoteHotFailed Int
tActive Int
aActive RemoteAddress
p SomeException
err) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteHotFailed"
             , Key
"targetActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tActive
             , Key
"actualActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aActive
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RemoteAddress -> Value
forall a. ToJSON a => a -> Value
toJSON RemoteAddress
p
             , Key
"reason" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= SomeException -> String
forall a. Show a => a -> String
show SomeException
err
             ]
  toObject TracingVerbosity
_verb (TraceDemoteHotDone Int
tActive Int
aActive RemoteAddress
p) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteHotDone"
             , Key
"targetActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
tActive
             , Key
"actualActive" Key -> Int -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
aActive
             , Key
"peer" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RemoteAddress -> Value
forall a. ToJSON a => a -> Value
toJSON RemoteAddress
p
             ]
  toObject TracingVerbosity
_verb (TraceDemoteAsynchronous Map RemoteAddress PeerStatus
msp) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"DemoteAsynchronous"
             , Key
"state" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Map RemoteAddress PeerStatus -> Value
forall a. ToJSON a => a -> Value
toJSON Map RemoteAddress PeerStatus
msp
             ]
  toObject TracingVerbosity
_verb TracePeerSelection RemoteAddress
TraceGovernorWakeup =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"GovernorWakeup"
             ]
  toObject TracingVerbosity
_verb (TraceChurnWait DiffTime
dt) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ChurnWait"
             , Key
"diffTime" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= DiffTime -> Value
forall a. ToJSON a => a -> Value
toJSON DiffTime
dt
             ]
  toObject TracingVerbosity
_verb (TraceChurnMode ChurnMode
c) =
    [Object] -> Object
forall a. Monoid a => [a] -> a
mconcat [ Key
"kind" Key -> Value -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ChurnMode"
             , Key
"event" Key -> String -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ChurnMode -> String
forall a. Show a => a -> String
show ChurnMode
c ]

-- Connection manager abstract state.  For explanation of each state see
-- <https://hydra.iohk.io/job/Cardano/ouroboros-network/native.network-docs.x86_64-linux/latest/download/2>
instance Aeson.ToJSON AbstractState where
    toJSON :: AbstractState -> Value
toJSON AbstractState
UnknownConnectionSt =
      [Pair] -> Value
Aeson.object [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UnknownConnectionSt" ]
    toJSON AbstractState
ReservedOutboundSt =
      [Pair] -> Value
Aeson.object [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"ReservedOutboundSt" ]
    toJSON (UnnegotiatedSt Provenance
provenance) =
      [Pair] -> Value
Aeson.object [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"UnnegotiatedSt"
                   , Key
"provenance" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (Provenance -> String) -> Provenance -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Provenance -> String
forall a. Show a => a -> String
show (Provenance -> Text) -> Provenance -> Text
forall a b. (a -> b) -> a -> b
$ Provenance
provenance)
                   ]
    toJSON (InboundIdleSt DataFlow
dataFlow) =
      [Pair] -> Value
Aeson.object [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InboundIdleSt"
                   , Key
"dataFlow" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (DataFlow -> String) -> DataFlow -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. DataFlow -> String
forall a. Show a => a -> String
show (DataFlow -> Text) -> DataFlow -> Text
forall a b. (a -> b) -> a -> b
$ DataFlow
dataFlow)
                   ]
    toJSON (InboundSt DataFlow
dataFlow) =
      [Pair] -> Value
Aeson.object [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"InboundSt"
                   , Key
"dataFlow" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (DataFlow -> String) -> DataFlow -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. DataFlow -> String
forall a. Show a => a -> String
show (DataFlow -> Text) -> DataFlow -> Text
forall a b. (a -> b) -> a -> b
$ DataFlow
dataFlow)
                   ]
    toJSON AbstractState
OutboundUniSt =
      [Pair] -> Value
Aeson.object [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"OutboundUniSt" ]
    toJSON (OutboundDupSt TimeoutExpired
timeoutExpired) =
      [Pair] -> Value
Aeson.object [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"OutboundDupSt"
                   , Key
"timeoutState" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text)
-> (TimeoutExpired -> String) -> TimeoutExpired -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. TimeoutExpired -> String
forall a. Show a => a -> String
show (TimeoutExpired -> Text) -> TimeoutExpired -> Text
forall a b. (a -> b) -> a -> b
$ TimeoutExpired
timeoutExpired)
                   ]
    toJSON (OutboundIdleSt DataFlow
dataFlow) =
      [Pair] -> Value
Aeson.object [ Key
"kind" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"OutboundIdleSt"
                   , Key
"dataFlow" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String (String -> Text
pack (String -> Text) -> (DataFlow -> String) -> DataFlow -> Text
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. DataFlow -> String
forall a. Show a => a -> String
show (DataFlow -> Text) -> DataFlow -> Text
forall a b. (a -> b) -> a -> b
$