Skip to content

Commit

Permalink
Merge #3854
Browse files Browse the repository at this point in the history
3854: Sync percentage fixed. r=deepfire a=denisshevchenko

Sync progress (as a part of `NodeState` datapoint) for `cardano-tracer` is fixed now.

Co-authored-by: Denis Shevchenko <[email protected]>
  • Loading branch information
iohk-bors[bot] and Denis Shevchenko authored May 11, 2022
2 parents e885010 + c76a8cd commit 0e24204
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cardano-node/src/Cardano/Node/Tracing/StateRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
{-# OPTIONS_GHC -Wno-orphans #-}

module Cardano.Node.Tracing.StateRep
( NodeState (..)
( AddedToCurrentChain (..)
, InitChainSelection (..)
, NodeState (..)
, OpeningDbs (..)
, Replays (..)
, StartupState (..)
, traceNodeStateChainDB
, traceNodeStateStartup
, traceNodeStateShutdown
Expand Down Expand Up @@ -65,7 +70,7 @@ data InitChainSelection
| InitChainSelected
deriving (Generic, FromJSON, ToJSON)

type SyncPercentage = Word8
type SyncPercentage = Double

data AddedToCurrentChain
= AddedToCurrentChain !EpochNo !SlotNo !SyncPercentage
Expand Down Expand Up @@ -143,9 +148,11 @@ traceNodeStateChainDB scp tr ev =
let RP.RealPoint slotSinceSystemStart _ = currentTip
-- The slot corresponding to the latest wall-clock time (our target).
slotNow <- getSlotForNow scp slotSinceSystemStart
let syncProgressPct = (unSlotNo slotSinceSystemStart `div` unSlotNo slotNow) * 100
let syncProgressPct :: SyncPercentage
syncProgressPct =
(fromIntegral (unSlotNo slotSinceSystemStart) / fromIntegral (unSlotNo slotNow)) * 100.0
traceWith tr $ NodeAddBlock $
AddedToCurrentChain ntEpoch (SlotNo sInEpoch) $ fromIntegral syncProgressPct
AddedToCurrentChain ntEpoch (SlotNo sInEpoch) syncProgressPct
_ -> return ()
_ -> return ()

Expand Down

0 comments on commit 0e24204

Please sign in to comment.