Skip to content

Commit febdf7b

Browse files
committed
Enhance observer options
Now it takes 2 subcommands * direct * blockfrost
1 parent 16f309e commit febdf7b

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

hydra-chain-observer/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ To run the observer in Direct Mode, provide the following arguments:
1313
For example:
1414

1515
``` shell
16-
hydra-chain-observer \
16+
hydra-chain-observer direct \
1717
--node-socket testnets/preprod/node.socket \
1818
--testnet-magic 1 \
1919
--start-chain-from "41948777.5d34af0f42be9823ebd35c2d83d5d879c5615ac17f7158bb9aa4ef89072455a7"
@@ -23,15 +23,15 @@ hydra-chain-observer \
2323
## Blockfrost Mode
2424

2525
To run the observer in Blockfrost Mode, provide the following arguments:
26-
- `--project`: file path to your Blockfrost project API token hash.
26+
- `--project-path`: file path to your Blockfrost project API token hash.
2727
> expected to be prefixed with environment (e.g. testnetA3C2E...)
2828
- (optional) `--start-from-block-hash`: specify a block hash to start observing from.
2929

3030
For example:
3131

3232
``` shell
33-
hydra-chain-observer \
34-
--project project_token_hash \
33+
hydra-chain-observer blockfrost \
34+
--project-path project_token_hash \
3535
--start-from-block-hash "5d34af0f42be9823ebd35c2d83d5d879c5615ac17f7158bb9aa4ef89072455a7"
3636
```
3737

hydra-chain-observer/src/Hydra/ChainObserver/Options.hs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import Hydra.Options (
1111
import Options.Applicative (
1212
Parser,
1313
ParserInfo,
14+
command,
1415
fullDesc,
1516
header,
1617
help,
1718
helper,
19+
hsubparser,
1820
info,
1921
long,
2022
metavar,
@@ -55,9 +57,9 @@ blockfrostOptionsParser =
5557
projectPathParser :: Parser FilePath
5658
projectPathParser =
5759
option str $
58-
long "project"
60+
long "project-path"
5961
<> metavar "BLOCKFROST_TOKEN_PATH"
60-
<> value "./"
62+
<> value "project_token_hash"
6163
<> help
6264
"The path where the Blockfrost project token hash is stored.\
6365
\It expects token prefixed with Blockfrost environment name\
@@ -73,10 +75,25 @@ startFromBlockHashParser =
7375
\used if the last known head state is older than given point. If not \
7476
\given and no known head state, the chain tip is used."
7577

78+
directOptionsInfo :: ParserInfo Options
79+
directOptionsInfo =
80+
info
81+
optionsParser
82+
(progDesc "Direct Mode")
83+
84+
blockfrostOptionsInfo :: ParserInfo Options
85+
blockfrostOptionsInfo =
86+
info
87+
blockfrostOptionsParser
88+
(progDesc "Blockfrost Mode")
89+
7690
hydraChainObserverOptions :: ParserInfo Options
7791
hydraChainObserverOptions =
7892
info
79-
( (optionsParser <|> blockfrostOptionsParser)
93+
( hsubparser
94+
( command "direct" directOptionsInfo
95+
<> command "blockfrost" blockfrostOptionsInfo
96+
)
8097
<**> helper
8198
)
8299
( fullDesc

hydra-explorer/src/Hydra/Explorer.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ run opts = do
8484
(getExplorerState, modifyExplorerState) <- createExplorerState
8585

8686
let chainObserverArgs =
87-
Options.toArgNodeSocket nodeSocket
87+
["direct"]
88+
<> Options.toArgNodeSocket nodeSocket
8889
<> Options.toArgNetworkId networkId
8990
<> toArgStartChainFrom startChainFrom
9091
race_

0 commit comments

Comments
 (0)