Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
Merge #206
Browse files Browse the repository at this point in the history
206: Add delegation interface types. r=nc6 a=nc6

Split out of nc/dlg-sts

Co-authored-by: Nicholas Clarke <nick@topos.org.uk>
  • Loading branch information
iohk-bors[bot] and nc6 committed Dec 7, 2018
2 parents 702160c + 65ab146 commit 3299ede
Showing 1 changed file with 35 additions and 11 deletions.
46 changes: 35 additions & 11 deletions specs/ledger/hs/src/delegation/Ledger/Delegation.hs
@@ -1,4 +1,8 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Ledger.Delegation where

import Control.Lens
Expand All @@ -14,6 +18,7 @@ import Data.Map.Strict (Map)

-- | A genesis key is a specialisation of a generic VKey.
newtype VKeyGen = VKeyGen VKey
deriving (Eq, Ord, Show)


data DCert = DCert
Expand All @@ -35,30 +40,49 @@ makeLenses ''DCert

-- | Delegation scheduling environment
data DSEnv = DSEnv
{ _dseAllowedDelegators :: Set VKeyGen
, _dseEpoch :: Epoch
, _dseSlot :: Slot
, _dseLiveness :: SlotCount
{ _dSEnvAllowedDelegators :: Set VKeyGen
, _dSEnvEpoch :: Epoch
, _dSEnvSlot :: Slot
, _dSEnvLiveness :: SlotCount
}

makeLenses ''DSEnv
makeFields ''DSEnv

-- | Delegation scheduling state
data DSState = DSState
{ _dssScheduledDelegations :: [(Slot, VKeyGen, VKey)]
, _dssKeyEpochDelegations :: Set (Epoch, VKeyGen)
{ _dSStateScheduledDelegations :: [(Slot, (VKeyGen, VKey))]
, _dSStateKeyEpochDelegations :: Set (Epoch, VKeyGen)
}

makeLenses ''DSState
makeFields ''DSState

-- | Delegation state
data DState = DState
{ _dsDelegationMap :: Map VKeyGen VKey
{ _dSStateDelegationMap :: Map VKeyGen VKey
-- | When was the last time each genesis key delegated.
, _dsLastDelegation :: Map VKeyGen Slot
, _dSStateLastDelegation :: Map VKeyGen Slot
}

makeLenses ''DState
makeFields ''DState

data DIEnv = DIEnv
{ _dIEnvAllowedDelegators :: Set VKeyGen
, _dIEnvEpoch :: Epoch
, _dIEnvSlot :: Slot
, _dIEnvLiveness :: SlotCount

}

makeFields ''DIEnv

data DIState = DIState
{ _dIStateDelegationMap :: Map VKeyGen VKey
, _dIStateLastDelegation :: Map VKeyGen Slot
, _dIStateScheduledDelegations :: [(Slot, (VKeyGen, VKey))]
, _dIStateKeyEpochDelegations :: Set (Epoch, VKeyGen)
}

makeFields ''DIState

--------------------------------------------------------------------------------
-- Transition systems
Expand Down

0 comments on commit 3299ede

Please sign in to comment.