| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Gini.Core.Protocol.Types.Block.Internal
Description
Block definitions
Synopsis
- data SignedBlock = SignedBlock {}
- powHashThreshold :: ByteString
- verifyRawPOW :: ByteString -> ProofOfWork -> Bool
- getBlockOrAccountForPoW :: UnsignedBlock -> Either Account BlockHash
- verifyProofOfWork :: SignedBlock -> Bool
- data UnsignedBlock
- data SendBlock = SendBlock {}
- data ReceiveBlock = ReceiveBlock {}
- data OpenBlock = OpenBlock {}
- data ChangeBlock = ChangeBlock {}
- data StateBlock = StateBlock {}
- isOpenBlock :: StateBlock -> Bool
- newtype Link = Link {}
- linkToAccount :: Link -> Either String Account
- linkToBlockHash :: Link -> Either String BlockHash
- blockHashToLink :: BlockHash -> Link
- accountToLink :: Account -> Link
- newtype ProofOfWork = ProofOfWork {}
- newtype BlockHashOrAccount = BlockHashOrAccount {}
- blockHashOrAccountToAccount :: BlockHashOrAccount -> Either String Account
- blockHashOrAccountToBlockHash :: BlockHashOrAccount -> Either String BlockHash
- data BlockType
- toBlockTypeValue :: BlockType -> Word8
- fromBlockTypeValue :: Word8 -> Maybe BlockType
- getSignedBlock :: BlockType -> Get SignedBlock
- putSignedBlock :: SignedBlock -> (BlockType, Put ())
- getUnsignedBlock :: BlockType -> Get UnsignedBlock
- putUnsignedBlock :: UnsignedBlock -> (BlockType, Put ())
- blockHasBigEndianWork :: UnsignedBlock -> Bool
- newtype Raw32ByteValue = Raw32ByteValue {}
- raw32ByteValueLength :: Int
- raw32ByteValueFromHexByteString :: ByteString -> Either String Raw32ByteValue
- generateRandomRaw32ByteValue :: MonadRandom m => m Raw32ByteValue
- raw32ByteValueToByteString :: Raw32ByteValue -> ByteString
- raw32ByteValueToAccount :: Raw32ByteValue -> Either String Account
- raw32ByteValueToBlockHash :: Raw32ByteValue -> Either String BlockHash
- data SignedBlockError
- verifySignedBlock :: SignedBlock -> Either SignedBlockError BlockHash
- data POWStatus
- generatedValidProofOfWork :: (MonadIO m, MonadUnliftIO m) => IORef POWStatus -> ByteString -> m ProofOfWork
Documentation
data SignedBlock #
Wraps a block with its proof of work and signature
Constructors
| SignedBlock | |
Fields
| |
Instances
verifyRawPOW :: ByteString -> ProofOfWork -> Bool #
Verify ProofOfWork for an UnsignedBlock.
verifyProofOfWork :: SignedBlock -> Bool #
Verifies Proof of work in the SignedBlock
data UnsignedBlock #
An unsigned block
Constructors
| UnsignedBlockSend !SendBlock | |
| UnsignedBlockReceive !ReceiveBlock | |
| UnsignedBlockOpen !OpenBlock | |
| UnsignedBlockChange !ChangeBlock | |
| UnsignedBlockState !StateBlock |
Instances
Contents of a send block
Constructors
| SendBlock | |
Fields
| |
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 #
Contents of a receive block
Constructors
| ReceiveBlock | |
Fields
| |
Instances
Contents of open block
Constructors
| OpenBlock | |
Fields
| |
Instances
| Eq OpenBlock # | |
| Show OpenBlock # | |
| Generic OpenBlock # | |
| Validity OpenBlock # | |
Defined in Gini.Core.Protocol.Types.Block.Internal | |
| Persist OpenBlock # | |
Defined in Gini.Core.Protocol.Types.Block.Internal | |
| type Rep OpenBlock # | |
Defined in Gini.Core.Protocol.Types.Block.Internal type Rep OpenBlock = D1 (MetaData "OpenBlock" "Gini.Core.Protocol.Types.Block.Internal" "gini-core-0.1.0.0-CYC9q60CJ5rDf5hHcbgY0V" False) (C1 (MetaCons "OpenBlock" PrefixI True) (S1 (MetaSel (Just "openBlockSource") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 BlockHash) :*: (S1 (MetaSel (Just "openBlockRepresentative") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Representative) :*: S1 (MetaSel (Just "openBlockAccount") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Account)))) | |
data ChangeBlock #
Contents of change block
Constructors
| ChangeBlock | |
Fields
| |
Instances
data StateBlock #
Contents of state block
Constructors
| StateBlock | |
Fields
| |
Instances
isOpenBlock :: StateBlock -> Bool #
Indicates if the StateBlock is an open transaction.
Contents of state block's link field
Constructors
| Link | |
Fields | |
Instances
| Eq Link # | |
| Show Link # | |
| IsString Link # | |
Defined in Gini.Core.Protocol.Types.Block.Internal Methods fromString :: String -> Link # | |
| Generic Link # | |
| Display Link # | |
Defined in Gini.Core.Protocol.Types.Block.Internal | |
| Validity Link # | |
Defined in Gini.Core.Protocol.Types.Block.Internal | |
| Persist Link # | |
Defined in Gini.Core.Protocol.Types.Block.Internal | |
| type Rep Link # | |
Defined in Gini.Core.Protocol.Types.Block.Internal type Rep Link = D1 (MetaData "Link" "Gini.Core.Protocol.Types.Block.Internal" "gini-core-0.1.0.0-CYC9q60CJ5rDf5hHcbgY0V" True) (C1 (MetaCons "Link" PrefixI True) (S1 (MetaSel (Just "unLink") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Raw32ByteValue))) | |
blockHashToLink :: BlockHash -> Link #
accountToLink :: Account -> Link #
newtype ProofOfWork #
Proof of work nonce
Constructors
| ProofOfWork | |
Fields | |
Instances
newtype BlockHashOrAccount #
Block hash or account address
Constructors
| BlockHashOrAccount | |
Fields | |
Instances
blockHashOrAccountToAccount :: BlockHashOrAccount -> Either String Account #
Convert BlockHashOrAccount to Account
blockHashOrAccountToBlockHash :: BlockHashOrAccount -> Either String BlockHash #
Convert BlockHashOrAccount to BlockHash
The block type determines what block is embedded in the message.
For some message types, block type is not relevant and the block type
is set to invalid or not_a_block
Constructors
| BlockTypeInvalid | 0x00 |
| BlockTypeNotABlock | 0x01 |
| BlockTypeSend | 0x02 |
| BlockTypeReceive | 0x03 |
| BlockTypeOpen | 0x04 |
| BlockTypeChange | 0x05 |
| BlockTypeState | 0x06 |
Instances
toBlockTypeValue :: BlockType -> Word8 #
fromBlockTypeValue :: Word8 -> Maybe BlockType #
getSignedBlock :: BlockType -> Get SignedBlock #
Deserialize a SignedBlock, given the BlockType value.
putSignedBlock :: SignedBlock -> (BlockType, Put ()) #
Returns a BlockType value and a closure that will serialize the
SignedBlock.
getUnsignedBlock :: BlockType -> Get UnsignedBlock #
Deserialize an UnsignedBlock, given the BlockType value.
putUnsignedBlock :: UnsignedBlock -> (BlockType, Put ()) #
Returns a BlockType value and a closure that will serialize the
UnsignedBlock.
blockHasBigEndianWork :: UnsignedBlock -> Bool #
Bool indicating whether a block's proof-of-work nonce should be serialized
as big-endian (True) or little-endian (False).
newtype Raw32ByteValue #
A generic 256-bit (32-byte) value rendered as hex.
Constructors
| Raw32ByteValue | |
Fields | |
Instances
data SignedBlockError #
Constructors
| SignedBlockSignatureInvalid | |
| SignedBlockDeserializationError | |
| SignedBlockProofOfWorkInvalid |
Instances
| Eq SignedBlockError # | |
Defined in Gini.Core.Protocol.Types.Block.Internal Methods (==) :: SignedBlockError -> SignedBlockError -> Bool # (/=) :: SignedBlockError -> SignedBlockError -> Bool # | |
| Show SignedBlockError # | |
Defined in Gini.Core.Protocol.Types.Block.Internal Methods showsPrec :: Int -> SignedBlockError -> ShowS # show :: SignedBlockError -> String # showList :: [SignedBlockError] -> ShowS # | |
| Display SignedBlockError # | |
Defined in Gini.Core.Protocol.Types.Block.Internal | |
verifySignedBlock :: SignedBlock -> Either SignedBlockError BlockHash #
Verifies the signature and produces block hash. (possibly other validations)
Constructors
| POWGenerated !ProofOfWork | Successfully Generated |
| POWNotGenerated !Word64 | Next nonce which the new thread has to validate against |
generatedValidProofOfWork :: (MonadIO m, MonadUnliftIO m) => IORef POWStatus -> ByteString -> m ProofOfWork #
Function for generating a valid ProofOfWork.
