Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try prune /acks on network discrepancy #1650

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions hydra-node/src/Hydra/Network/Reliability.hs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ withReliability ::
-- | Underlying network component providing consuming and sending channels.
NetworkComponent m (Authenticated (ReliableMsg (Heartbeat inbound))) (ReliableMsg (Heartbeat outbound)) a ->
NetworkComponent m (Authenticated (Heartbeat inbound)) (Heartbeat outbound) a
withReliability tracer MessagePersistence{saveAcks, loadAcks, appendMessage, loadMessages} me otherParties withRawNetwork callback action = do
acksCache <- loadAcks >>= newTVarIO
withReliability tracer MessagePersistence{appendMessage, loadMessages} me otherParties withRawNetwork callback action = do
acksCache <- newTVarIO mempty
sentMessages <- loadMessages >>= newTVarIO . Seq.fromList
resendQ <- newTQueueIO
let ourIndex = fromMaybe (error "This cannot happen because we constructed the list with our party inside.") (findPartyIndex me)
Expand All @@ -242,13 +242,11 @@ withReliability tracer MessagePersistence{saveAcks, loadAcks, appendMessage, loa
case msg of
Data{} -> do
localCounter <- atomically $ cacheMessage msg >> incrementAckCounter
saveAcks localCounter
appendMessage msg
traceWith tracer BroadcastCounter{ourIndex, localCounter}
broadcast $ ReliableMsg localCounter msg
Ping{} -> do
localCounter <- readTVarIO acksCache
saveAcks localCounter
traceWith tracer BroadcastPing{ourIndex, localCounter}
broadcast $ ReliableMsg localCounter msg
}
Expand Down Expand Up @@ -288,8 +286,12 @@ withReliability tracer MessagePersistence{saveAcks, loadAcks, appendMessage, loa
let newAcks = constructAcks loadedAcks partyIndex
lift $ writeTVar acksCache newAcks
return (True, partyIndex, newAcks)
| otherwise ->
-- other messages are dropped
| messageAckForParty <= knownAckForParty ->
-- old messages are dropped
return (False, partyIndex, loadedAcks)
| otherwise -> do
-- others
lift $ writeTVar acksCache mempty
return (False, partyIndex, loadedAcks)

case eShouldCallbackWithKnownAcks of
Expand Down
Loading