Skip to content

Commit

Permalink
Assign precedence values to pool certificates extracted from Shelley …
Browse files Browse the repository at this point in the history
…blocks.
  • Loading branch information
jonathanknowles committed Jul 3, 2020
1 parent 7c82265 commit 66038f4
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions lib/shelley/src/Cardano/Wallet/Shelley/Pools.hs
Expand Up @@ -53,7 +53,6 @@ import Cardano.Wallet.Primitive.Types
, PoolId
, PoolRegistrationCertificate (..)
, PoolRetirementCertificate (..)
, Precedence (..)
, ProtocolParameters
, SlotId
, SlotLength (..)
Expand Down Expand Up @@ -362,13 +361,26 @@ monitorStakePools tr gp nl db@DBLayer{..} = do
liftIO $ traceWith tr $ MsgErrProduction e
Right () ->
pure ()
forM_ registrations $ \case
Registration cert -> do

-- A Shelley block can contain multiple certificates relating to
-- the same pool.
--
-- The order in which certificates appear within a block determines
-- their precedence relative to one another.
--
-- Certificates that appear later in a block have higher precedence
-- than certificates that appear earlier.
--
-- TODO: Insert link to the specification to justify this decision.
--
let precedences = [minBound ..]
forM_ (registrations `zip` precedences) $ \case
(Registration cert, precedence) -> do
liftIO $ traceWith tr $ MsgStakePoolRegistration cert
putPoolRegistration (slot, minBound) cert
Retirement cert -> do
putPoolRegistration (slot, precedence) cert
(Retirement cert, precedence) -> do
liftIO $ traceWith tr $ MsgStakePoolRetirement cert
putPoolRetirement (slot, minBound) cert
putPoolRetirement (slot, precedence) cert
pure Continue

monitorMetadata
Expand Down

0 comments on commit 66038f4

Please sign in to comment.