diff --git a/src/journal/src/Journal/Internal.hs b/src/journal/src/Journal/Internal.hs index bdf4f2d7..6108f74e 100644 --- a/src/journal/src/Journal/Internal.hs +++ b/src/journal/src/Journal/Internal.hs @@ -51,14 +51,14 @@ tryClaim jour len = do let index = indexByTermCount termCount activePartitionIndex = index rt <- readRawTail (jMetadata jour) index - initTermId <- readInitialTermId (jMetadata jour) - termLen <- readTermLength (jMetadata jour) + let initTermId = jInitialTermId jour + termLen = jTermLength jour + posBitsToShift = jPositionBitsToShift jour -- XXX: cache and read these from there? let termId = rawTailTermId rt termOffset = rawTailTermOffset rt termLen - termBeginPosition = - computeTermBeginPosition termId (positionBitsToShift termLen) initTermId + termBeginPosition = computeTermBeginPosition termId posBitsToShift initTermId jLog = logg (jLogger jour) jLog ("tryClaim, termCount: " ++ show (unTermCount termCount)) diff --git a/src/journal/src/Journal/MP.hs b/src/journal/src/Journal/MP.hs index e029a4a1..cfd76d59 100644 --- a/src/journal/src/Journal/MP.hs +++ b/src/journal/src/Journal/MP.hs @@ -317,13 +317,13 @@ tryClaim jour len = do let activePartitionIndex = indexByTermCount termCount termBuffer = jTermBuffers jour Vector.! unPartitionIndex activePartitionIndex rawTail <- readRawTail (jMetadata jour) activePartitionIndex - initTermId <- readInitialTermId (jMetadata jour) - let termLen = unCapacity (getCapacity termBuffer) - termId = rawTailTermId rawTail - termOffset = rawTailTermOffset rawTail (int2Int32 termLen) - position = - computeTermBeginPosition termId (positionBitsToShift (int2Int32 termLen)) initTermId - + int322Int64 (unTermOffset termOffset) + let initTermId = jInitialTermId jour + termLen = jTermLength jour + termId = rawTailTermId rawTail + termOffset = rawTailTermOffset rawTail termLen + posBitsToShift = jPositionBitsToShift jour + position = computeTermBeginPosition termId posBitsToShift initTermId + + int322Int64 (unTermOffset termOffset) if unTermCount termCount /= unTermId (termId - initTermId) then return (Left AdminAction) -- XXX: what does this mean to end up here?