Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync percentage fixed. #3854

Merged
merged 1 commit into from
May 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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