hydra-tx-0.19.0: Hydra transaction library
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Tx.Snapshot

Synopsis

SnapshotNumber and SnapshotVersion

newtype SnapshotNumber Source #

Instances

Instances details
Arbitrary SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

FromJSON SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

parseJSON :: Value -> Parser SnapshotNumber

parseJSONList :: Value -> Parser [SnapshotNumber]

omittedField :: Maybe SnapshotNumber

ToJSON SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Enum SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Generic SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Associated Types

type Rep SnapshotNumber :: Type -> Type Source #

Num SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Integral SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Real SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Show SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

FromCBOR SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

ToCBOR SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

toCBOR :: SnapshotNumber -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy SnapshotNumber -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [SnapshotNumber] -> Size

Eq SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Ord SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

type Rep SnapshotNumber Source # 
Instance details

Defined in Hydra.Tx.Snapshot

type Rep SnapshotNumber = D1 ('MetaData "SnapshotNumber" "Hydra.Tx.Snapshot" "hydra-tx-0.19.0-CNt37yoHV6SLHPMLDZKDue" 'True) (C1 ('MetaCons "UnsafeSnapshotNumber" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural)))

newtype SnapshotVersion Source #

Instances

Instances details
Arbitrary SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

FromJSON SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

ToJSON SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Enum SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Generic SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Associated Types

type Rep SnapshotVersion :: Type -> Type Source #

Num SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Integral SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Real SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Show SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

FromCBOR SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

ToCBOR SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

toCBOR :: SnapshotVersion -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy SnapshotVersion -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [SnapshotVersion] -> Size

Eq SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Ord SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

type Rep SnapshotVersion Source # 
Instance details

Defined in Hydra.Tx.Snapshot

type Rep SnapshotVersion = D1 ('MetaData "SnapshotVersion" "Hydra.Tx.Snapshot" "hydra-tx-0.19.0-CNt37yoHV6SLHPMLDZKDue" 'True) (C1 ('MetaCons "UnsafeSnapshotVersion" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural)))

Snapshot

data Snapshot tx Source #

Constructors

Snapshot 

Fields

Instances

Instances details
(Arbitrary tx, Arbitrary (UTxOType tx)) => Arbitrary (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

arbitrary :: Gen (Snapshot tx)

shrink :: Snapshot tx -> [Snapshot tx]

IsTx tx => FromJSON (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

parseJSON :: Value -> Parser (Snapshot tx)

parseJSONList :: Value -> Parser [Snapshot tx]

omittedField :: Maybe (Snapshot tx)

IsTx tx => ToJSON (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

toJSON :: Snapshot tx -> Value

toEncoding :: Snapshot tx -> Encoding

toJSONList :: [Snapshot tx] -> Value

toEncodingList :: [Snapshot tx] -> Encoding

omitField :: Snapshot tx -> Bool

Generic (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Associated Types

type Rep (Snapshot tx) :: Type -> Type Source #

Methods

from :: Snapshot tx -> Rep (Snapshot tx) x Source #

to :: Rep (Snapshot tx) x -> Snapshot tx Source #

IsTx tx => Show (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

(Typeable tx, FromCBOR tx, FromCBOR (UTxOType tx)) => FromCBOR (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

fromCBOR :: Decoder s (Snapshot tx)

label :: Proxy (Snapshot tx) -> Text

(Typeable tx, ToCBOR tx, ToCBOR (UTxOType tx)) => ToCBOR (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

toCBOR :: Snapshot tx -> Encoding

encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy (Snapshot tx) -> Size

encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [Snapshot tx] -> Size

IsTx tx => SignableRepresentation (Snapshot tx) Source #

Binary representation of snapshot signatures. That is, concatenated CBOR for Snapshot, $sel:version:Snapshot, $sel:number:Snapshot, utxoHash and utxoToDecommitHash according to CDDL schemata:

headId = bytes .size 16 version = uint number = uint utxoHash = bytes utxoToCommitHash = bytes utxoToDecommitHash = bytes

where hashes are the result of applying hashUTxO.

Instance details

Defined in Hydra.Tx.Snapshot

IsTx tx => Eq (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

(==) :: Snapshot tx -> Snapshot tx -> Bool Source #

(/=) :: Snapshot tx -> Snapshot tx -> Bool Source #

type Rep (Snapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

ConfirmedSnapshot

data ConfirmedSnapshot tx Source #

A snapshot that can be used to close a head with. Either the initial one, or when it was signed by all parties, i.e. it is confirmed.

Instances

Instances details
(Arbitrary tx, Arbitrary (UTxOType tx), IsTx tx) => Arbitrary (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

IsTx tx => FromJSON (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

parseJSON :: Value -> Parser (ConfirmedSnapshot tx)

parseJSONList :: Value -> Parser [ConfirmedSnapshot tx]

omittedField :: Maybe (ConfirmedSnapshot tx)

IsTx tx => ToJSON (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Methods

toJSON :: ConfirmedSnapshot tx -> Value

toEncoding :: ConfirmedSnapshot tx -> Encoding

toJSONList :: [ConfirmedSnapshot tx] -> Value

toEncodingList :: [ConfirmedSnapshot tx] -> Encoding

omitField :: ConfirmedSnapshot tx -> Bool

Generic (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

Associated Types

type Rep (ConfirmedSnapshot tx) :: Type -> Type Source #

IsTx tx => Show (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

IsTx tx => Eq (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

type Rep (ConfirmedSnapshot tx) Source # 
Instance details

Defined in Hydra.Tx.Snapshot

type Rep (ConfirmedSnapshot tx) = D1 ('MetaData "ConfirmedSnapshot" "Hydra.Tx.Snapshot" "hydra-tx-0.19.0-CNt37yoHV6SLHPMLDZKDue" 'False) (C1 ('MetaCons "InitialSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "initialUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx))) :+: C1 ('MetaCons "ConfirmedSnapshot" 'PrefixI 'True) (S1 ('MetaSel ('Just "snapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Snapshot tx)) :*: S1 ('MetaSel ('Just "signatures") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MultiSignature (Snapshot tx)))))

getSnapshot :: ConfirmedSnapshot tx -> Snapshot tx Source #

Safely get a Snapshot from a confirmed snapshot.

NOTE: While we could use $sel:snapshot:InitialSnapshot directly, this is a record-field accessor which may become partial (and lead to unnoticed runtime errors) if we ever add a new branch to the sumtype. So, we explicitely define a getter which will force us into thinking about changing the signature properly if this happens.

isInitialSnapshot :: ConfirmedSnapshot tx -> Bool Source #

Tell whether a snapshot is the initial snapshot coming from the collect-com transaction.

genConfirmedSnapshot Source #

Arguments

:: IsTx tx 
=> HeadId 
-> SnapshotVersion

Exact snapshot version to generate.

-> SnapshotNumber

The lower bound on snapshot number to generate. If this is 0, then we can generate an InitialSnapshot or a ConfirmedSnapshot. Otherwise we generate only ConfirmedSnapshot with a number strictly superior to this lower bound.

-> UTxOType tx 
-> Maybe (UTxOType tx) 
-> Maybe (UTxOType tx) 
-> [SigningKey HydraKey] 
-> Gen (ConfirmedSnapshot tx)