-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 'Split haskell lib, fanout to L1, and get balance' (…
…#3) from demo3 into develop Reviewed-on: https://code.obsidian.systems/HydraNow/hydra-pay/pulls/3
- Loading branch information
Showing
26 changed files
with
1,472 additions
and
603 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: hydra-pay-core | ||
version: 0.1 | ||
cabal-version: >=1.10 | ||
build-type: Simple | ||
|
||
library | ||
hs-source-dirs: src | ||
build-depends: | ||
aeson | ||
, aeson-gadt-th | ||
, base | ||
, beam-core | ||
, bytestring | ||
, cardano-addresses | ||
, cardano-api | ||
, cardano-ledger-core | ||
, constraints-extras | ||
, containers | ||
, directory | ||
, hexstring | ||
, lens | ||
, mtl | ||
, network | ||
, process | ||
, stm | ||
, text | ||
, time | ||
, transformers | ||
|
||
default-extensions: | ||
ConstraintKinds | ||
DataKinds | ||
DeriveGeneric | ||
DerivingStrategies | ||
FlexibleContexts | ||
FlexibleInstances | ||
GADTs | ||
LambdaCase | ||
MultiParamTypeClasses | ||
OverloadedStrings | ||
QuantifiedConstraints | ||
RankNTypes | ||
RecursiveDo | ||
ScopedTypeVariables | ||
TypeApplications | ||
TypeFamilies | ||
UndecidableInstances | ||
|
||
exposed-modules: | ||
HydraPay.Cardano.Hydra.Api | ||
HydraPay.Cardano.Hydra.Api.ClientInput | ||
HydraPay.Cardano.Hydra.ChainConfig | ||
HydraPay.Cardano.Hydra.RunningHead | ||
HydraPay.Logging | ||
HydraPay.Orphans | ||
HydraPay.PaymentChannel | ||
HydraPay.PortRange | ||
HydraPay.Types | ||
HydraPay.Utils | ||
|
||
ghc-options: | ||
-Wall -Wredundant-constraints -Wincomplete-uni-patterns | ||
-Wincomplete-record-updates -O -fno-show-valid-hole-fits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
hydra-pay-core/src/HydraPay/Cardano/Hydra/Api/ClientInput.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- | | ||
|
||
module HydraPay.Cardano.Hydra.Api.ClientInput where | ||
|
||
import GHC.Generics | ||
import Data.Aeson | ||
|
||
|
||
data ClientInput | ||
= Init | ||
| Abort | ||
| Commit {utxo :: Value} | ||
| NewTx {transaction :: Value } | ||
| GetUTxO | ||
| Close | ||
| Contest | ||
| Fanout | ||
deriving (Generic, Show, Eq) | ||
|
||
instance FromJSON ClientInput | ||
instance ToJSON ClientInput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{-# Language TemplateHaskell #-} | ||
module HydraPay.Cardano.Hydra.ChainConfig where | ||
|
||
import Control.Lens | ||
|
||
data HydraChainConfig = HydraChainConfig | ||
{ _hydraChainConfig_ledgerGenesis :: FilePath | ||
, _hydraChainConfig_ledgerProtocolParams :: FilePath | ||
} | ||
|
||
|
||
makeLenses ''HydraChainConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module HydraPay.Cardano.Hydra.RunningHead where | ||
|
||
import Control.Concurrent | ||
import Control.Concurrent.STM | ||
import Data.Map (Map) | ||
import System.IO | ||
import System.Process | ||
|
||
import HydraPay.Cardano.Hydra.Api | ||
import HydraPay.PortRange | ||
import qualified Cardano.Api as Api | ||
|
||
-- | A running Hydra Head | ||
data RunningHydraHead = RunningHydraHead | ||
{ _hydraHead_status :: TVar HydraHeadStatus | ||
, _hydraHead_handles :: Map Api.AddressAny HydraNode | ||
} | ||
|
||
data HydraHeadStatus | ||
= HydraHead_Uninitialized | ||
| HydraHead_Initializing | ||
| HydraHead_Open | ||
| HydraHead_Closed | ||
| HydraHead_Finalized | ||
| HydraHead_Aborted | ||
|
||
type ProcessInfo = (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) | ||
|
||
data HydraNode = HydraNode | ||
{ _hydraNode_apiPort :: Port | ||
, _hydraNode_processInfo :: ProcessInfo | ||
, _hydraNode_communicationThread :: ThreadId | ||
, _hydraNode_status :: TVar HydraNodeStatus | ||
, _hydraNode_pendingRequests :: TMVar (Map Int HydraNodeRequest) | ||
, _hydraNode_requestQueue :: TBQueue ClientInput | ||
} | ||
|
||
data HydraNodeStatus | ||
= HydraNodeStatus_Unavailable | ||
| HydraNodeStatus_Replaying | ||
| HydraNodeStatus_Replayed | ||
| HydraNodeStatus_PeersConnected | ||
| HydraNodeStatus_Closed -- ^ TODO do we need this? Should we be removing this node after it is close? But what about if we haven't fanned out yet | ||
deriving (Eq, Show) | ||
|
||
data HydraNodeRequest = HydraNodeRequest | ||
{ _hydraNodeRequest_id :: Int | ||
, _hydraNodeRequest_clientInput :: ClientInput | ||
, _hydraNodeRequest_mailbox :: TMVar ServerOutput | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.