Skip to content

Commit

Permalink
p8: Move the suspended flag (#564)
Browse files Browse the repository at this point in the history
This moves the suspended flag from AccountInfo to AccountStakingInfo.Baker
  • Loading branch information
drsk0 authored Oct 22, 2024
1 parent 64fb7ff commit d7eb356
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion concordium-grpc-api
2 changes: 1 addition & 1 deletion haskell-src/Concordium/GRPC2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ instance ToProto AccountStakingInfo where
case asiPoolInfo of
Nothing -> return ()
Just asipi -> ProtoFields.poolInfo .= toProto asipi
ProtoFields.isSuspended .= asiIsSuspended
)
)
toProto AccountStakingDelegated{..} =
Expand Down Expand Up @@ -619,7 +620,6 @@ instance ToProto AccountInfo where
ProtoFields.maybe'stake .= toProto aiStakingInfo
ProtoFields.cooldowns .= fmap toProto aiAccountCooldowns
ProtoFields.availableBalance .= toProto aiAccountAvailableAmount
ProtoFields.isSuspended .= aiAccountIsSuspended

instance ToProto Wasm.Parameter where
type Output Wasm.Parameter = Proto.Parameter
Expand Down
24 changes: 13 additions & 11 deletions haskell-src/Concordium/Types/Accounts.hs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,11 @@ data AccountStakingInfo
asiStakeEarnings :: !Bool,
asiBakerInfo :: !BakerInfo,
asiPendingChange :: !(StakePendingChange' UTCTime),
asiPoolInfo :: !(Maybe BakerPoolInfo)
asiPoolInfo :: !(Maybe BakerPoolInfo),
-- | Flag indicating whether the account is currently suspended. A suspended account
-- is not participating in the consensus protocol. The `asiIsSuspended` flag does not
-- have any effect on stake or delegators of a validator.
asiIsSuspended :: !Bool
}
| -- | The account is delegating stake to a baker.
AccountStakingDelegated
Expand All @@ -613,7 +617,10 @@ toAccountStakingInfo epochConv (AccountStakeBaker AccountBaker{..}) =
asiPendingChange = pcTime <$> _bakerPendingChange,
asiPoolInfo = case _accountBakerInfo of
BakerInfoExV0{} -> Nothing
BakerInfoExV1{..} -> Just _bieBakerPoolInfo
BakerInfoExV1{..} -> Just _bieBakerPoolInfo,
asiIsSuspended = case _accountBakerInfo of
BakerInfoExV0{} -> False
BakerInfoExV1{..} -> fromCondDef _bieAccountIsSuspended False
}
where
pcTime (PendingChangeEffectiveV0 e) = epochConv e
Expand Down Expand Up @@ -663,7 +670,8 @@ accountStakingInfoToJSON AccountStakingBaker{..} = ["accountBaker" .= bi]
"bakerId" .= (asiBakerInfo ^. bakerIdentity),
"bakerElectionVerifyKey" .= (asiBakerInfo ^. bakerElectionVerifyKey),
"bakerSignatureVerifyKey" .= (asiBakerInfo ^. bakerSignatureVerifyKey),
"bakerAggregationVerifyKey" .= (asiBakerInfo ^. bakerAggregationVerifyKey)
"bakerAggregationVerifyKey" .= (asiBakerInfo ^. bakerAggregationVerifyKey),
"bakerIsSuspended" .= asiIsSuspended
]
<> pendingChangeToJSON asiPendingChange
<> maybe [] (\bpi -> ["bakerPoolInfo" .= bpi]) asiPoolInfo
Expand Down Expand Up @@ -751,12 +759,7 @@ data AccountInfo = AccountInfo
-- pre-cooldown or pre-pre-cooldown (e.g. if the cooldown interval has been decreased).
aiAccountCooldowns :: ![Cooldown],
-- | The balance of the account that is available for transactions.
aiAccountAvailableAmount :: !Amount,
-- | Flag indicating whether the account is currently suspended. A
-- suspended account is in effect not participating in the consensus
-- protocol. The aiAccountIsSuspended flag does not have any effect on
-- stake or delegators of a validator.
aiAccountIsSuspended :: !Bool
aiAccountAvailableAmount :: !Amount
}
deriving (Eq, Show)

Expand All @@ -774,8 +777,7 @@ accountInfoPairs AccountInfo{..} =
"accountIndex" .= aiAccountIndex,
"accountAddress" .= aiAccountAddress,
"accountCooldowns" .= aiAccountCooldowns,
"accountAvailableAmount" .= aiAccountAvailableAmount,
"accountIsSuspended" .= aiAccountIsSuspended
"accountAvailableAmount" .= aiAccountAvailableAmount
]
<> accountStakingInfoToJSON aiStakingInfo

Expand Down

0 comments on commit d7eb356

Please sign in to comment.