Skip to content

Commit 2cb21c2

Browse files
authored
Fix updating of API server projections (#1927)
We always need to update the read models irrespective of whether a StateEvent does map to a ServerOutput or not. We discovered when investigating why `/snapshot/last-seen` was not showing correct information while the `hydra-node` is running, but was correct after a restart. --- * [x] CHANGELOG update not needed (we introduced this bug in this release) * [x] Documentation update not needed * [x] Haddocks update not needed * [x] No new TODOs introduced
2 parents fd42411 + e6d4184 commit 2cb21c2

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

hydra-node/src/Hydra/API/Server.hs

+10-8
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,19 @@ withAPIServer config env party eventSource tracer chain pparams serverOutputFilt
148148
action
149149
( EventSink
150150
{ putEvent = \event@StateEvent{stateChanged} -> do
151+
-- Update our read models
152+
atomically $ do
153+
update headStatusP stateChanged
154+
update commitInfoP stateChanged
155+
update snapshotUtxoP stateChanged
156+
update seenSnapshotP stateChanged
157+
update snapshotConfirmedP stateChanged
158+
update headIdP stateChanged
159+
update pendingDepositsP stateChanged
160+
-- Send to the client if it maps to a server output
151161
case mkTimedServerOutputFromStateEvent event of
152162
Nothing -> pure ()
153163
Just timedOutput -> do
154-
atomically $ do
155-
update headStatusP stateChanged
156-
update commitInfoP stateChanged
157-
update snapshotUtxoP stateChanged
158-
update seenSnapshotP stateChanged
159-
update snapshotConfirmedP stateChanged
160-
update headIdP stateChanged
161-
update pendingDepositsP stateChanged
162164
atomically $ writeTChan responseChannel (Left timedOutput)
163165
}
164166
, Server{sendMessage = atomically . writeTChan responseChannel . Right}

0 commit comments

Comments
 (0)