@@ -11,6 +11,7 @@ import Prelude
11
11
12
12
import Data.Aeson (FromJSON , ToJSON )
13
13
import Data.Map (Map )
14
+ import Data.Monoid (Last (.. ), getLast )
14
15
import Data.Text (Text , pack )
15
16
import Data.Time.Clock (NominalDiffTime , UTCTime )
16
17
import Data.Version (showVersion )
@@ -45,8 +46,9 @@ import Ouroboros.Network.Subscription.Ip (IPSubscriptionTarget (..))
45
46
46
47
import Cardano.Api.Protocol.Types (BlockType (.. ), protocolInfo )
47
48
import Cardano.Logging
49
+ import Cardano.Node.Configuration.POM (NodeConfiguration (.. ), ncProtocol )
48
50
import Cardano.Node.Configuration.Socket
49
- import Cardano.Node.Protocol.Types (Protocol ( .. ), SomeConsensusProtocol (.. ))
51
+ import Cardano.Node.Protocol.Types (SomeConsensusProtocol (.. ))
50
52
51
53
import Cardano.Git.Rev (gitRev )
52
54
import Paths_cardano_node (version )
@@ -166,16 +168,16 @@ docNodeInfoTraceEvent = Documented [
166
168
167
169
-- | Prepare basic info about the node. This info will be sent to 'cardano-tracer'.
168
170
prepareNodeInfo
169
- :: Protocol
171
+ :: NodeConfiguration
170
172
-> SomeConsensusProtocol
171
173
-> TraceConfig
172
174
-> UTCTime
173
175
-> IO NodeInfo
174
- prepareNodeInfo ptcl (SomeConsensusProtocol whichP pForInfo) tc nodeStartTime = do
176
+ prepareNodeInfo nc (SomeConsensusProtocol whichP pForInfo) tc nodeStartTime = do
175
177
nodeName <- prepareNodeName
176
178
return $ NodeInfo
177
179
{ niName = nodeName
178
- , niProtocol = pack . show $ ptcl
180
+ , niProtocol = pack . show . ncProtocol $ nc
179
181
, niVersion = pack . showVersion $ version
180
182
, niCommit = gitRev
181
183
, niStartTime = nodeStartTime
@@ -208,7 +210,15 @@ prepareNodeInfo ptcl (SomeConsensusProtocol whichP pForInfo) tc nodeStartTime =
208
210
prepareNodeName =
209
211
case tcNodeName tc of
210
212
Just aName -> return aName
211
- Nothing -> pack <$> getHostName
213
+ Nothing -> do
214
+ -- The user didn't specify node's name in the configuration.
215
+ -- In this case we should form node's name as "host:port", where 'host' and 'port'
216
+ -- are taken from '--host-addr' and '--port' CLI-parameters correspondingly.
217
+ let SocketConfig hostIPv4 hostIPv6 port _ = ncSocketConfig nc
218
+ hostName <- case (show <$> hostIPv6) <> (show <$> hostIPv4) of
219
+ Last (Just addr) -> return addr
220
+ Last Nothing -> getHostName
221
+ return . pack $ hostName <> maybe " " ((" :" ++ ) . show ) (getLast port)
212
222
213
223
-- | This information is taken from 'BasicInfoShelleyBased'. It is required for
214
224
-- 'cardano-tracer' service (particularly, for RTView).
0 commit comments