Skip to content
Permalink
Browse files

Revert the change to `getBlockCount`. [skip ci]

  • Loading branch information...
dnadales committed Mar 14, 2019
1 parent a32ce62 commit c2c2ed7c0c197120210c80d173f008e702c8e02b
@@ -51,7 +51,6 @@ library
Cardano.Chain.Common.AddressHash
Cardano.Chain.Common.Attributes
Cardano.Chain.Common.BlockCount
Cardano.Chain.Common.BlockCount.JSON
Cardano.Chain.Common.ChainDifficulty
Cardano.Chain.Common.Lovelace
Cardano.Chain.Common.LovelacePortion
@@ -9,15 +9,13 @@ where

import Cardano.Prelude

import Data.Aeson.TH (defaultOptions, deriveJSON, fieldLabelModifier)
import Data.Aeson.TH (defaultOptions, deriveJSON)
import Formatting.Buildable (Buildable)

import Cardano.Binary.Class (Bi(..))

import Cardano.Chain.Common.BlockCount.JSON (unToGet)

newtype BlockCount = BlockCount
{ unBlockCount :: Word64
{ getBlockCount :: Word64
} deriving ( Eq
, Ord
, Num
@@ -32,8 +30,8 @@ newtype BlockCount = BlockCount
)

instance Bi BlockCount where
encode = encode . unBlockCount
encode = encode . getBlockCount
decode = BlockCount <$> decode
encodedSizeExpr size pxy = size (unBlockCount <$> pxy)
encodedSizeExpr size pxy = size (getBlockCount <$> pxy)

deriveJSON (defaultOptions { fieldLabelModifier = unToGet }) ''BlockCount
deriveJSON defaultOptions ''BlockCount

This file was deleted.

Oops, something went wrong.
@@ -18,7 +18,7 @@ import Cardano.Chain.Slotting.SlotCount (SlotCount)
-- | Security parameter expressed in number of slots. It uses chain quality
-- property. It's basically @blkSecurityParam / chainQualityThreshold@.
kSlotSecurityParam :: BlockCount -> SlotCount
kSlotSecurityParam = fromIntegral . (*) 2 . unBlockCount
kSlotSecurityParam = fromIntegral . (*) 2 . getBlockCount

-- | Minimal chain quality (number of blocks divided by number of
-- slots) necessary for security of the system.
@@ -27,4 +27,4 @@ kChainQualityThreshold k = realToFrac k / realToFrac (kSlotSecurityParam k)

-- | Number of slots inside one epoch
kEpochSlots :: BlockCount -> SlotCount
kEpochSlots = fromIntegral . (*) 10 . unBlockCount
kEpochSlots = fromIntegral . (*) 10 . getBlockCount
@@ -98,8 +98,8 @@ registerEndorsement env st endorsement =
isConfirmedAndStable upId = upId `M.member` scps
where
-- Stable and confirmed proposals.
scps = M.filter (currentSlot - _2 k <=) confirmedProposals
_2 x = 2 * unBlockCount x
scps = M.filter (stableAt <=) confirmedProposals
stableAt = currentSlot - FlatSlotId (2 * getBlockCount k)

pps = adoptedProtocolParameters env
pv = endorsementProtocolVersion endorsement

0 comments on commit c2c2ed7

Please sign in to comment.
You can’t perform that action at this time.