Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
-
data
TraceEvent
blk
- = DBAlreadyClosed
- | BlockAlreadyHere ( HeaderHash blk)
- | Truncate ( ParseError blk) FsPath BlockOffset
- | InvalidFileNames [ FsPath ]
- newtype BlockOffset = BlockOffset { }
- newtype BlockSize = BlockSize { }
- type FileId = Int
- data InternalState blk h
-
data
OpenState
blk h =
OpenState
{
- currentWriteHandle :: !( Handle h)
- currentWritePath :: ! FsPath
- currentWriteId :: ! FileId
- currentWriteOffset :: ! Word64
- currentMap :: !( Index blk)
- currentRevMap :: !( ReverseIndex blk)
- currentSuccMap :: !( SuccessorsIndex blk)
- currentMaxSlotNo :: ! MaxSlotNo
- type ReverseIndex blk = Map ( HeaderHash blk) ( InternalBlockInfo blk)
- type SuccessorsIndex blk = Map ( ChainHash blk) ( Set ( HeaderHash blk))
-
data
VolatileDBEnv
m blk =
forall
h.
Eq
h =>
VolatileDBEnv
{
- hasFS :: !( HasFS m h)
- varInternalState :: !( RAWLock m ( InternalState blk h))
- maxBlocksPerFile :: ! BlocksPerFile
- checkIntegrity :: !(blk -> Bool )
- codecConfig :: !( CodecConfig blk)
- tracer :: !( Tracer m ( TraceEvent blk))
- dbIsOpen :: InternalState blk h -> Bool
- type ModifyOpenState m blk h = StateT ( OpenState blk h) ( WithTempRegistry ( OpenState blk h) m)
- appendOpenState :: forall blk m a. ( IOLike m, Typeable blk, StandardHash blk) => VolatileDBEnv m blk -> ( forall h. Eq h => HasFS m h -> ModifyOpenState m blk h a) -> m a
- closeOpenHandles :: HasFS m h -> OpenState blk h -> m ()
- mkOpenState :: forall m blk h. ( HasCallStack , IOLike m, GetPrevHash blk, HasBinaryBlockInfo blk, HasNestedContent Header blk, DecodeDisk blk ( ByteString -> blk), Eq h) => CodecConfig blk -> HasFS m h -> (blk -> Bool ) -> BlockValidationPolicy -> Tracer m ( TraceEvent blk) -> BlocksPerFile -> WithTempRegistry ( OpenState blk h) m ( OpenState blk h)
- withOpenState :: forall blk m r. ( IOLike m, StandardHash blk, Typeable blk) => VolatileDBEnv m blk -> ( forall h. HasFS m h -> OpenState blk h -> m r) -> m r
- writeOpenState :: forall blk m a. ( IOLike m, Typeable blk, StandardHash blk) => VolatileDBEnv m blk -> ( forall h. Eq h => HasFS m h -> ModifyOpenState m blk h a) -> m a
Tracing
data TraceEvent blk Source #
DBAlreadyClosed | |
BlockAlreadyHere ( HeaderHash blk) | |
Truncate ( ParseError blk) FsPath BlockOffset | |
InvalidFileNames [ FsPath ] |
Instances
State types
newtype BlockOffset Source #
The offset at which a block is stored in a file.
Instances
Eq BlockOffset Source # | |
Defined in Ouroboros.Consensus.Storage.VolatileDB.Impl.Types (==) :: BlockOffset -> BlockOffset -> Bool Source # (/=) :: BlockOffset -> BlockOffset -> Bool Source # |
|
Show BlockOffset Source # | |
Generic BlockOffset Source # | |
Defined in Ouroboros.Consensus.Storage.VolatileDB.Impl.Types from :: BlockOffset -> Rep BlockOffset x Source # to :: Rep BlockOffset x -> BlockOffset Source # |
|
NoThunks BlockOffset Source # | |
type Rep BlockOffset Source # | |
Defined in Ouroboros.Consensus.Storage.VolatileDB.Impl.Types
type
Rep
BlockOffset
=
D1
('
MetaData
"BlockOffset" "Ouroboros.Consensus.Storage.VolatileDB.Impl.Types" "ouroboros-consensus-0.1.0.1-DT4Cvwf63DZKctsEvaJqCU" '
True
) (
C1
('
MetaCons
"BlockOffset" '
PrefixI
'
True
) (
S1
('
MetaSel
('
Just
"unBlockOffset") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
Word64
)))
|
Instances
Eq BlockSize Source # | |
Show BlockSize Source # | |
Generic BlockSize Source # | |
NoThunks BlockSize Source # | |
type Rep BlockSize Source # | |
Defined in Ouroboros.Consensus.Storage.VolatileDB.Impl.Types
type
Rep
BlockSize
=
D1
('
MetaData
"BlockSize" "Ouroboros.Consensus.Storage.VolatileDB.Impl.Types" "ouroboros-consensus-0.1.0.1-DT4Cvwf63DZKctsEvaJqCU" '
True
) (
C1
('
MetaCons
"BlockSize" '
PrefixI
'
True
) (
S1
('
MetaSel
('
Just
"unBlockSize") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
Word32
)))
|
data InternalState blk h Source #
Instances
Generic ( InternalState blk h) Source # | |
Defined in Ouroboros.Consensus.Storage.VolatileDB.Impl.State from :: InternalState blk h -> Rep ( InternalState blk h) x Source # to :: Rep ( InternalState blk h) x -> InternalState blk h Source # |
|
( StandardHash blk, Typeable blk) => NoThunks ( InternalState blk h) Source # | |
type Rep ( InternalState blk h) Source # | |
Defined in Ouroboros.Consensus.Storage.VolatileDB.Impl.State
type
Rep
(
InternalState
blk h) =
D1
('
MetaData
"InternalState" "Ouroboros.Consensus.Storage.VolatileDB.Impl.State" "ouroboros-consensus-0.1.0.1-DT4Cvwf63DZKctsEvaJqCU" '
False
) (
C1
('
MetaCons
"DbClosed" '
PrefixI
'
False
) (
U1
::
Type
->
Type
)
:+:
C1
('
MetaCons
"DbOpen" '
PrefixI
'
False
) (
S1
('
MetaSel
('
Nothing
::
Maybe
Symbol
) '
NoSourceUnpackedness
'
SourceStrict
'
DecidedStrict
) (
Rec0
(
OpenState
blk h))))
|
Internal state when the database is open.
OpenState | |
|
Instances
type ReverseIndex blk = Map ( HeaderHash blk) ( InternalBlockInfo blk) Source #
We map the header hash of each block to the
InternalBlockInfo
.
type SuccessorsIndex blk = Map ( ChainHash blk) ( Set ( HeaderHash blk)) Source #
For each block, we store the set of all blocks which have this block as a predecessor (set of successors).
data VolatileDBEnv m blk Source #
forall h. Eq h => VolatileDBEnv | |
|
dbIsOpen :: InternalState blk h -> Bool Source #
State helpers
type ModifyOpenState m blk h = StateT ( OpenState blk h) ( WithTempRegistry ( OpenState blk h) m) Source #
Shorthand
appendOpenState :: forall blk m a. ( IOLike m, Typeable blk, StandardHash blk) => VolatileDBEnv m blk -> ( forall h. Eq h => HasFS m h -> ModifyOpenState m blk h a) -> m a Source #
Append to the open state. Reads can happen concurrently with this operation.
NOTE: This is safe in terms of throwing FsErrors.
closeOpenHandles :: HasFS m h -> OpenState blk h -> m () Source #
Close the handles in the
OpenState
.
Idempotent, as closing a handle is idempotent.
NOTE: does not wrap
FsError
s and must be called within
wrapFsError
or
tryVolatileDB
.
mkOpenState :: forall m blk h. ( HasCallStack , IOLike m, GetPrevHash blk, HasBinaryBlockInfo blk, HasNestedContent Header blk, DecodeDisk blk ( ByteString -> blk), Eq h) => CodecConfig blk -> HasFS m h -> (blk -> Bool ) -> BlockValidationPolicy -> Tracer m ( TraceEvent blk) -> BlocksPerFile -> WithTempRegistry ( OpenState blk h) m ( OpenState blk h) Source #
withOpenState :: forall blk m r. ( IOLike m, StandardHash blk, Typeable blk) => VolatileDBEnv m blk -> ( forall h. HasFS m h -> OpenState blk h -> m r) -> m r Source #
Perform an action that accesses the internal state of an open database.
In case the database is closed, a
ClosedDBError
is thrown.
In case an
UnexpectedFailure
is thrown while the action is being run, the
database is closed to prevent further appending to a database in a
potentially inconsistent state. All other exceptions will leave the database
open.
writeOpenState :: forall blk m a. ( IOLike m, Typeable blk, StandardHash blk) => VolatileDBEnv m blk -> ( forall h. Eq h => HasFS m h -> ModifyOpenState m blk h a) -> m a Source #
Write to the open state. No reads or appends can concurrently with this operation.
NOTE: This is safe in terms of throwing FsErrors.