Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add delegation state to wallet state.
- Loading branch information
Showing
4 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 17 additions & 1 deletion
18
lib/wallet/src/Cardano/Wallet/DB/Store/Delegations/Model.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,35 @@ | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# OPTIONS_GHC -Wno-orphans #-} | ||
module Cardano.Wallet.DB.Store.Delegations.Model | ||
( Delegations | ||
, DeltaDelegations | ||
) where | ||
|
||
|
||
import Prelude | ||
|
||
import Cardano.Pool.Types | ||
( PoolId ) | ||
import Cardano.Wallet.Delegation.Model | ||
( History, Operation ) | ||
( History, Operation (..) ) | ||
import Cardano.Wallet.Primitive.Types | ||
( SlotNo ) | ||
import Formatting | ||
( bformat, intercalated, later ) | ||
import Formatting.Buildable | ||
( Buildable (..) ) | ||
|
||
-- | Wallet delegation history | ||
type Delegations = History SlotNo PoolId | ||
|
||
-- | Delta of wallet delegation history. As always with deltas, the | ||
-- order of the operations matters and it's reversed! (ask the architects) | ||
type DeltaDelegations = [Operation SlotNo PoolId] | ||
|
||
instance Buildable DeltaDelegations where | ||
build = bformat $ intercalated ", " $ later $ \case | ||
Register slot -> "Register " <> build slot | ||
Deregister slot -> "Deregister " <> build slot | ||
Delegate pool slot -> "Delegate " <> build pool <> " " <> build slot | ||
Rollback slot -> "Rollback " <> build slot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters