This repository has been archived by the owner on Aug 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CO-390] Create a 'demo' executable for cardano-sl-wallet-new
This code makes use of the 'Cardano.Wallet.Demo' module and show how it can be used to spawn a demo cluster of nodes. More details in the README.md
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{-| Demo cluster of wallet nodes. See cluster/README.md -} | ||
|
||
module Main where | ||
|
||
import Universum | ||
|
||
import Control.Concurrent.Async (waitAny) | ||
import System.IO (BufferMode (..), hSetBuffering, stdout) | ||
|
||
import Cardano.Cluster (MaxWaitingTime (..), NodeName (..), | ||
NodeType (..), RunningNode (..), startCluster, | ||
waitForNode) | ||
|
||
|
||
-- | Cluster configuration can be tweaked via ENV vars. | ||
-- Each ENV var is prefixed with the following. | ||
-- | ||
-- (e.g. `DEMO_NO_CLIENT_AUTH=True`) | ||
prefix :: String | ||
prefix = "DEMO_" | ||
|
||
|
||
main :: IO () | ||
main = void $ do | ||
hSetBuffering stdout NoBuffering -- Instead of LineBuffering | ||
|
||
putTextLn "Cluster is starting..." | ||
cluster <- startCluster prefix | ||
[ ("core0", NodeCore) | ||
, ("core1", NodeCore) | ||
, ("core2", NodeCore) | ||
, ("core3", NodeCore) | ||
, ("relay", NodeRelay) | ||
, ("wallet", NodeEdge) | ||
] | ||
handles <- forM cluster $ \case | ||
RunningCoreNode (NodeName nodeId) handle -> do | ||
putTextLn $ "..." <> nodeId <> " has no health-check API." | ||
return handle | ||
|
||
RunningRelayNode (NodeName nodeId) handle -> do | ||
putTextLn $ "..." <> nodeId <> " has no health-check API." | ||
return handle | ||
|
||
RunningWalletNode (NodeName nodeId) client handle -> do | ||
putText "..." >> waitForNode client (MaxWaitingTime 30) | ||
putTextLn $ nodeId <> " OK!" | ||
return handle | ||
putTextLn "Cluster is (probably) ready!" | ||
|
||
waitAny handles |