Skip to content

Commit

Permalink
Add support for fetching tip through cardano-ping
Browse files Browse the repository at this point in the history
Added NodeToClientVersionV17
Update cardano-ping to version 0.4.0.2 in order to support fetching tip.
  • Loading branch information
karknu authored and Jimbo4350 committed Sep 9, 2024
1 parent e64120d commit 840ee52
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repository cardano-haskell-packages
-- you need to run if you change them
index-state:
, hackage.haskell.org 2024-08-08T19:27:29Z
, cardano-haskell-packages 2024-09-05T16:30:09Z
, cardano-haskell-packages 2024-09-09T11:32:44Z

packages:
cardano-cli
Expand Down Expand Up @@ -57,3 +57,4 @@ write-ghc-environment-files: always
-- IMPORTANT
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

2 changes: 1 addition & 1 deletion cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ library
cardano-ledger-byron >=1.0.1.0,
cardano-ledger-core,
cardano-ledger-shelley,
cardano-ping ^>=0.2.0.13,
cardano-ping ^>=0.4,
cardano-prelude,
cardano-slotting ^>=0.2.0.0,
cardano-strict-containers ^>=0.1,
Expand Down
1 change: 1 addition & 0 deletions cardano-cli/src/Cardano/CLI/Commands/Ping.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ data PingCmd = PingCmd
, pingCmdJson :: !Bool
, pingCmdQuiet :: !Bool
, pingOptsHandshakeQuery :: !Bool
, pingOptsGetTip :: !Bool
}
deriving (Eq, Show)
7 changes: 7 additions & 0 deletions cardano-cli/src/Cardano/CLI/Options/Ping.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,10 @@ pPing =
"Query the supported protocol versions using the handshake protocol and terminate the connection."
]
)
<*> ( Opt.switch $
mconcat
[ Opt.long "tip"
, Opt.short 't'
, Opt.help "Request tip then exit."
]
)
6 changes: 5 additions & 1 deletion cardano-cli/src/Cardano/CLI/Run/Ping.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pingClient stdout stderr cmd = CNP.pingClient stdout stderr opts
, CNP.pingOptsPort = pingCmdPort cmd
, CNP.pingOptsMagic = pingCmdMagic cmd
, CNP.pingOptsHandshakeQuery = pingOptsHandshakeQuery cmd
, CNP.pingOptsGetTip = pingOptsGetTip cmd
}

runPingCmd :: PingCmd -> ExceptT PingClientCmdError IO ()
Expand All @@ -80,7 +81,10 @@ runPingCmd options = do
return ([addr], CNP.supportedNodeToClientVersions $ pingCmdMagic options)

-- Logger async thread handle
laid <- liftIO . async $ CNP.logger msgQueue (pingCmdJson options) (pingOptsHandshakeQuery options)
laid <-
liftIO . async $
CNP.logger msgQueue (pingCmdJson options) (pingOptsHandshakeQuery options) (pingOptsGetTip options)

-- Ping client thread handles
caids <-
forM addresses $
Expand Down

0 comments on commit 840ee52

Please sign in to comment.