Skip to content

Commit 1e7123f

Browse files
committed
Short-cut delivery in Hydra.Node.Network
This is now replicating the previous behavior of Hydra.Node into the aggregated Network stack.
1 parent 33f86d1 commit 1e7123f

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

hydra-node/src/Hydra/Node/Network.hs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ import Hydra.Prelude hiding (fromList, replicate)
7373

7474
import Control.Tracer (Tracer)
7575
import Hydra.Logging (traceWith)
76-
import Hydra.Logging.Messages (HydraLog (..))
77-
import Hydra.Network (Host (..), IP, NetworkCallback (..), NetworkComponent, NodeId, PortNumber)
76+
import Hydra.Logging.Messages (HydraLog)
77+
import Hydra.Logging.Messages qualified as Log
78+
import Hydra.Network (Host (..), IP, Network (..), NetworkCallback (..), NetworkComponent, NodeId, PortNumber)
7879
import Hydra.Network.Authenticate (Authenticated (..), Signed, withAuthentication)
7980
import Hydra.Network.Heartbeat (Heartbeat (..), withHeartbeat)
8081
import Hydra.Network.Message (
@@ -132,14 +133,14 @@ withNetwork tracer configuration callback action = do
132133
let localHost = Host{hostname = show host, port}
133134
me = deriveParty signingKey
134135
numberOfParties = length $ me : otherParties
135-
messagePersistence <- configureMessagePersistence (contramap Node tracer) persistenceDir numberOfParties
136+
messagePersistence <- configureMessagePersistence (contramap Log.Node tracer) persistenceDir numberOfParties
136137

137138
let reliability =
138139
withFlipHeartbeats $
139-
withReliability (contramap Reliability tracer) messagePersistence me otherParties $
140-
withAuthentication (contramap Authentication tracer) signingKey otherParties $
140+
withReliability (contramap Log.Reliability tracer) messagePersistence me otherParties $
141+
withAuthentication (contramap Log.Authentication tracer) signingKey otherParties $
141142
withOuroborosNetwork
142-
(contramap Network tracer)
143+
(contramap Log.Network tracer)
143144
HydraNetworkConfig
144145
{ protocolVersion = currentHydraVersionedProtocol
145146
, localHost
@@ -149,8 +150,13 @@ withNetwork tracer configuration callback action = do
149150
deliver . ConnectivityEvent $ HandshakeFailure{remoteHost, ourVersion, theirVersions}
150151
)
151152

152-
withHeartbeat nodeId reliability (NetworkCallback{deliver = deliver . mapHeartbeat}) $ \network ->
153-
action network
153+
withHeartbeat nodeId reliability (NetworkCallback{deliver = deliver . mapHeartbeat}) $ \Network{broadcast} ->
154+
action
155+
Network
156+
{ broadcast = \msg -> do
157+
broadcast msg
158+
deliver (ReceivedMessage{sender = deriveParty signingKey, msg})
159+
}
154160
where
155161
NetworkCallback{deliver} = callback
156162

0 commit comments

Comments
 (0)