Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data BlockType
- data BlockStatus
- data OpenBlock = OpenBlock {}
- data SendBlock = SendBlock {}
- data ReceiveBlock = ReceiveBlock {}
- newtype ChangeBlock = ChangeBlock {}
- data Block (t :: BlockType) (s :: BlockStatus) = Block {}
- data BlockValidationError
- = BlockSignatureInvalid
- | BlockProofOfWorkInvalid
- | OpenBlockExistsError
- | RepresentativeDoesNotExist
- | MissingUnclaimedSendBlock
- | SourceIsNotSendBlock
- | DestinationMismatch
- | PreviousBlockInvalid
- | InsufficientFunds
- | InvalidArithmetic !String
- | AmountTooSmall
- | InvalidLink String
- | AccountDoesNotExist
- | AccountIsBurned
- | ChangeSameRepresentative
- | SignedBlockError !SignedBlockError
- type family BlockFamily (t :: BlockType) where ...
- type NetworkBlockType = BlockType
- handleBlock :: forall t s a. Typeable t => Block t s -> (Block Open s -> a) -> (Block Send s -> a) -> (Block Receive s -> a) -> (Block Change s -> a) -> a
- getBlockType :: forall t s. Typeable t => Block t s -> BlockType
- toSignedBlock :: Typeable t => Block t s -> SignedBlock
Documentation
Instances
Eq BlockType # | |
Show BlockType # | |
PersistField BlockType # | |
Defined in Gini.Core.Types.Block.Internal toPersistValue :: BlockType -> PersistValue fromPersistValue :: PersistValue -> Either Text BlockType | |
PersistFieldSql BlockType # | |
Defined in Gini.Core.Types.Block.Internal |
data BlockStatus #
Instances
Eq BlockStatus # | |
Defined in Gini.Core.Types.Block.Internal (==) :: BlockStatus -> BlockStatus -> Bool # (/=) :: BlockStatus -> BlockStatus -> Bool # | |
Show BlockStatus # | |
Defined in Gini.Core.Types.Block.Internal showsPrec :: Int -> BlockStatus -> ShowS # show :: BlockStatus -> String # showList :: [BlockStatus] -> ShowS # |
Open block acts as:
- Initial block on the account chain
- Receive the initial funds from the source block
- Set the representative
Contents of a send block
SendBlock | |
|
Instances
Eq SendBlock # | |
Show SendBlock # | |
Generic SendBlock # | |
Validity SendBlock # | |
Defined in Gini.Core.Protocol.Types.Block.Internal | |
Persist SendBlock # | |
Defined in Gini.Core.Protocol.Types.Block.Internal | |
type Rep SendBlock # | |
Defined in Gini.Core.Protocol.Types.Block.Internal type Rep SendBlock = D1 (MetaData "SendBlock" "Gini.Core.Protocol.Types.Block.Internal" "gini-core-0.1.0.0-CYC9q60CJ5rDf5hHcbgY0V" False) (C1 (MetaCons "SendBlock" PrefixI True) (S1 (MetaSel (Just "sendBlockPrevious") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 BlockHash) :*: (S1 (MetaSel (Just "sendBlockDestination") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Account) :*: S1 (MetaSel (Just "sendBlockBalance") SourceUnpack SourceStrict DecidedStrict) (Rec0 Amount)))) |
data ReceiveBlock #
Receive block:
- Increases the account balance by recieving money from the source block, which in turn must be a send type block
- Optionally setting the representative
Instances
Eq ReceiveBlock # | |
Defined in Gini.Core.Types.Block.Internal (==) :: ReceiveBlock -> ReceiveBlock -> Bool # (/=) :: ReceiveBlock -> ReceiveBlock -> Bool # | |
Show ReceiveBlock # | |
Defined in Gini.Core.Types.Block.Internal showsPrec :: Int -> ReceiveBlock -> ShowS # show :: ReceiveBlock -> String # showList :: [ReceiveBlock] -> ShowS # |
newtype ChangeBlock #
Change block can only change the representative. But considering that any block can do it we only keep around the previous block hash.
Instances
Eq ChangeBlock # | |
Defined in Gini.Core.Types.Block.Internal (==) :: ChangeBlock -> ChangeBlock -> Bool # (/=) :: ChangeBlock -> ChangeBlock -> Bool # | |
Show ChangeBlock # | |
Defined in Gini.Core.Types.Block.Internal showsPrec :: Int -> ChangeBlock -> ShowS # show :: ChangeBlock -> String # showList :: [ChangeBlock] -> ShowS # |
data Block (t :: BlockType) (s :: BlockStatus) #
This Block
captures everything that the SignedBlock
has plus some more
information derived from the database. In other words, SignedBlock
can
always be reconstructed from the Block
with the help of toSignedBlock
function, but in order to go in the opposite direction we must go through the
database and it can only be done when the SignedBlock
is being validated
and applied to the blockchain.
Here are a few things that are available over the SignedBlock
:
- We know what was the previous balance, so we know how much money being transacted, if any.
- Unlike the
StateBlock
, here we know if the money being sent, received or it is a mere change of representative - We know at the type level what type of block it is. As such, there is no
ambiguous
Link
field. - We know that the
Block
is valid due to theBlockStatus
kind and we even know if it has already been stored (Committed
) in the database or not. In words validity ofSignedBlock
depends not only on it's content but also on the current state of the database, whileBlock
encodes this information at the type level. - Representative is available for all blocks, since for any
StateBlock
reprensentative can be changed and must be present even in the case when such change does not occur.
Block | |
|
data BlockValidationError #
Instances
Eq BlockValidationError # | |
Defined in Gini.Core.Types.Block.Internal (==) :: BlockValidationError -> BlockValidationError -> Bool # (/=) :: BlockValidationError -> BlockValidationError -> Bool # | |
Show BlockValidationError # | |
Defined in Gini.Core.Types.Block.Internal showsPrec :: Int -> BlockValidationError -> ShowS # show :: BlockValidationError -> String # showList :: [BlockValidationError] -> ShowS # | |
Display BlockValidationError # | |
Defined in Gini.Core.Types.Block.Internal display :: BlockValidationError -> Utf8Builder |
type family BlockFamily (t :: BlockType) where ... #
type NetworkBlockType = BlockType #
handleBlock :: forall t s a. Typeable t => Block t s -> (Block Open s -> a) -> (Block Send s -> a) -> (Block Receive s -> a) -> (Block Change s -> a) -> a #
A way to handle individual block types. See toSignedBlock
for an example how to use it.
getBlockType :: forall t s. Typeable t => Block t s -> BlockType #
Bring the type level BlockType
to the value level.
toSignedBlock :: Typeable t => Block t s -> SignedBlock #
Convert a validated or commited block into a raw signed block that is ready for serialization and network transmission