Skip to content

Commit e835263

Browse files
committed
WIP
1 parent 3fb0484 commit e835263

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Util/StreamingLedgerTables.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ module Ouroboros.Consensus.Util.StreamingLedgerTables
1919
) where
2020

2121
import Cardano.Slotting.Slot
22-
import Codec.CBOR.Decoding (Decoder, decodeBreakOr, decodeMapLenOrIndef)
23-
import Codec.CBOR.Encoding (Encoding, encodeBreak, encodeMapLenIndef)
22+
import Codec.CBOR.Decoding (Decoder, decodeBreakOr, decodeListLen, decodeMapLenOrIndef)
23+
import Codec.CBOR.Encoding (Encoding, encodeBreak, encodeListLen, encodeMapLenIndef)
2424
import Codec.CBOR.Read
2525
import Codec.CBOR.Write
2626
import Control.Concurrent.Class.MonadMVar
@@ -101,7 +101,7 @@ yieldCborMapS ::
101101
Stream (Of ByteString) m () ->
102102
Stream (Of (a, b)) (ExceptT DeserialiseFailure m) (Stream (Of ByteString) m ())
103103
yieldCborMapS decK decV = execStateT $ do
104-
hoist lift (decodeCbor decodeMapLenOrIndef) >>= \case
104+
hoist lift (decodeCbor decodeListLen >> decodeCbor decodeMapLenOrIndef) >>= \case
105105
Nothing -> go
106106
Just n -> replicateM_ n yieldKV
107107
where
@@ -232,7 +232,7 @@ sinkInMemoryS ::
232232
ExceptT DeserialiseFailure m ()
233233
sinkInMemoryS _ writeChunkSize encK encV (SomeHasFS fs) fp s =
234234
ExceptT $ withFile fs (mkFsPath [fp]) (WriteMode MustBeNew) $ \hdl -> do
235-
void $ hPutSome fs hdl $ toStrictByteString encodeMapLenIndef
235+
void $ hPutSome fs hdl $ toStrictByteString (encodeListLen 1 <> encodeMapLenIndef)
236236
e <- runExceptT $ go hdl writeChunkSize mempty s
237237
case e of
238238
Left err -> pure $ Left err
@@ -241,11 +241,11 @@ sinkInMemoryS _ writeChunkSize encK encV (SomeHasFS fs) fp s =
241241
pure $ Right ()
242242
where
243243
go tb 0 m s' = do
244-
lift $ void $ hPutSome fs tb $ toStrictByteString $ mconcat [encK k <> encV v | (k, v) <- m]
244+
lift $ void $ hPutSome fs tb $ toStrictByteString $ mconcat [encK k <> encV v | (k, v) <- reverse m]
245245
go tb writeChunkSize mempty s'
246246
go tb n m s' = do
247247
mbs <- S.uncons s'
248248
case mbs of
249249
Nothing ->
250-
lift $ void $ hPutSome fs tb $ toStrictByteString $ mconcat [encK k <> encV v | (k, v) <- m]
250+
lift $ void $ hPutSome fs tb $ toStrictByteString $ mconcat [encK k <> encV v | (k, v) <- reverse m]
251251
Just (item, s'') -> go tb (n - 1) (item : m) s''

0 commit comments

Comments
 (0)