Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
SignedBlock | |
|
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
UnsignedBlockSend !SendBlock | |
UnsignedBlockReceive !ReceiveBlock | |
UnsignedBlockOpen !OpenBlock | |
UnsignedBlockChange !ChangeBlock | |
UnsignedBlockState !StateBlock |
Instances
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 #
Contents of a receive block
ReceiveBlock | |
|
Instances
Contents of open block
OpenBlock | |
|
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
ChangeBlock | |
|
Instances
data StateBlock #
Contents of state block
StateBlock | |
|
Instances
isOpenBlock :: StateBlock -> Bool #
Indicates if the StateBlock
is an open transaction.
Contents of state block's link field
Instances
Eq Link # | |
Show Link # | |
IsString Link # | |
Defined in Gini.Core.Protocol.Types.Block.Internal fromString :: String -> Link # | |
Generic Link # | |
Display Link # | |
Defined in Gini.Core.Protocol.Types.Block.Internal display :: Link -> Utf8Builder textDisplay :: Link -> Text | |
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
Instances
newtype BlockHashOrAccount #
Block hash or account address
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
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.
Instances
data SignedBlockError #
Instances
Eq SignedBlockError # | |
Defined in Gini.Core.Protocol.Types.Block.Internal (==) :: SignedBlockError -> SignedBlockError -> Bool # (/=) :: SignedBlockError -> SignedBlockError -> Bool # | |
Show SignedBlockError # | |
Defined in Gini.Core.Protocol.Types.Block.Internal showsPrec :: Int -> SignedBlockError -> ShowS # show :: SignedBlockError -> String # showList :: [SignedBlockError] -> ShowS # | |
Display SignedBlockError # | |
Defined in Gini.Core.Protocol.Types.Block.Internal display :: SignedBlockError -> Utf8Builder textDisplay :: SignedBlockError -> Text |
verifySignedBlock :: SignedBlock -> Either SignedBlockError BlockHash #
Verifies the signature and produces block hash. (possibly other validations)
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
.