Skip to content

Commit

Permalink
Enhance observer options
Browse files Browse the repository at this point in the history
Now it takes 2 subcommands
* direct
* blockfrost
  • Loading branch information
ffakenz committed Sep 26, 2024
1 parent 8f4b128 commit 1ed191a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
8 changes: 4 additions & 4 deletions hydra-chain-observer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ To run the observer in Direct Mode, provide the following arguments:
For example:

``` shell
hydra-chain-observer \
hydra-chain-observer direct \
--node-socket testnets/preprod/node.socket \
--testnet-magic 1 \
--start-chain-from "41948777.5d34af0f42be9823ebd35c2d83d5d879c5615ac17f7158bb9aa4ef89072455a7"
Expand All @@ -23,15 +23,15 @@ hydra-chain-observer \
## Blockfrost Mode

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

For example:

``` shell
hydra-chain-observer \
--project project_token_hash \
hydra-chain-observer blockfrost \
--project-path project_token_hash \
--start-from-block-hash "5d34af0f42be9823ebd35c2d83d5d879c5615ac17f7158bb9aa4ef89072455a7"
```

23 changes: 20 additions & 3 deletions hydra-chain-observer/src/Hydra/ChainObserver/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import Hydra.Options (
import Options.Applicative (
Parser,
ParserInfo,
command,
fullDesc,
header,
help,
helper,
hsubparser,
info,
long,
metavar,
Expand Down Expand Up @@ -55,9 +57,9 @@ blockfrostOptionsParser =
projectPathParser :: Parser FilePath
projectPathParser =
option str $
long "project"
long "project-path"
<> metavar "BLOCKFROST_TOKEN_PATH"
<> value "./"
<> value "project_token_hash"
<> help
"The path where the Blockfrost project token hash is stored.\
\It expects token prefixed with Blockfrost environment name\
Expand All @@ -73,10 +75,25 @@ startFromBlockHashParser =
\used if the last known head state is older than given point. If not \
\given and no known head state, the chain tip is used."

directOptionsInfo :: ParserInfo Options
directOptionsInfo =
info
optionsParser
(progDesc "Direct Mode")

blockfrostOptionsInfo :: ParserInfo Options
blockfrostOptionsInfo =
info
blockfrostOptionsParser
(progDesc "Blockfrost Mode")

hydraChainObserverOptions :: ParserInfo Options
hydraChainObserverOptions =
info
( (optionsParser <|> blockfrostOptionsParser)
( hsubparser
( command "direct" directOptionsInfo
<> command "blockfrost" blockfrostOptionsInfo
)
<**> helper
)
( fullDesc
Expand Down
3 changes: 2 additions & 1 deletion hydra-explorer/src/Hydra/Explorer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ run opts = do
(getExplorerState, modifyExplorerState) <- createExplorerState

let chainObserverArgs =
Options.toArgNodeSocket nodeSocket
["direct"]
<> Options.toArgNodeSocket nodeSocket
<> Options.toArgNetworkId networkId
<> toArgStartChainFrom startChainFrom
race_
Expand Down

0 comments on commit 1ed191a

Please sign in to comment.