This repository was archived by the owner on Aug 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 631
[CDEC-485] Move Block data types from core to chain package #3351
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d1ffbca
[CDEC-485] Move some JsonLog functions to chain
ruhatch 44b3685
[CDEC-485] Move Pos.Core.StateLock to db
ruhatch 4ebad9c
[CDEC-485] Move Pos.Core.Block files to chain
ruhatch 5ba48ca
[CDEC-485] Appease stylish-haskell
ruhatch 04ccf68
[CDEC-485] Appease hlint
ruhatch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
3 changes: 2 additions & 1 deletion
3
core/src/Pos/Core/Block/Blockchain.hs → chain/src/Pos/Chain/Block/Blockchain.hs
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{-# OPTIONS_GHC -Wno-unused-imports #-} | ||
{-# OPTIONS_GHC -Wno-dodgy-exports #-} | ||
|
||
module Pos.Chain.Block.Genesis | ||
( module Pos.Chain.Block.Genesis.Instances | ||
, module Pos.Chain.Block.Genesis.Lens | ||
, module Pos.Chain.Block.Genesis.Types | ||
) where | ||
|
||
import Pos.Chain.Block.Genesis.Instances | ||
import Pos.Chain.Block.Genesis.Lens | ||
import Pos.Chain.Block.Genesis.Types |
This file contains hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
core/src/Pos/Core/Block/Genesis/Types.hs → chain/src/Pos/Chain/Block/Genesis/Types.hs
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module Pos.Chain.Block.JsonLog | ||
( jlCreatedBlock | ||
, jlAdoptedBlock | ||
) where | ||
|
||
import Universum | ||
|
||
import Formatting (sformat) | ||
|
||
import Pos.Chain.Block.Blockchain (gbHeader, gbhPrevBlock) | ||
import Pos.Chain.Block.Genesis (genBlockEpoch) | ||
import Pos.Chain.Block.Union (Block, HeaderHash, headerHash, | ||
headerHashF, mainBlockSlot, mainBlockTxPayload) | ||
import Pos.Core (HasConfiguration, SlotId (..), getEpochIndex, | ||
getSlotIndex, mkLocalSlotIndex) | ||
import Pos.Core.JsonLog.LogEvents (JLBlock (..), JLEvent (..)) | ||
import Pos.Core.Txp (txpTxs) | ||
import Pos.Crypto (hash, hashHexF) | ||
|
||
-- | Return event of created block. | ||
jlCreatedBlock :: HasConfiguration => Block -> JLEvent | ||
jlCreatedBlock block = JLCreatedBlock $ JLBlock {..} | ||
where | ||
jlHash = showHeaderHash $ headerHash block | ||
jlPrevBlock = showHeaderHash $ case block of | ||
Left gB -> view gbhPrevBlock (gB ^. gbHeader) | ||
Right mB -> view gbhPrevBlock (mB ^. gbHeader) | ||
jlSlot = (getEpochIndex $ siEpoch slot, getSlotIndex $ siSlot slot) | ||
jlTxs = case block of | ||
Left _ -> [] | ||
Right mB -> map fromTx . toList $ mB ^. mainBlockTxPayload . txpTxs | ||
slot :: SlotId | ||
slot = case block of | ||
Left gB -> let slotZero = case mkLocalSlotIndex 0 of | ||
Right sz -> sz | ||
Left _ -> error "impossible branch" | ||
in SlotId (gB ^. genBlockEpoch) slotZero | ||
Right mB -> mB ^. mainBlockSlot | ||
fromTx = sformat hashHexF . hash | ||
|
||
-- | Returns event of created 'Block'. | ||
jlAdoptedBlock :: Block -> JLEvent | ||
jlAdoptedBlock = JLAdoptedBlock . showHeaderHash . headerHash | ||
|
||
showHeaderHash :: HeaderHash -> Text | ||
showHeaderHash = sformat headerHashF |
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{-# OPTIONS_GHC -Wno-unused-imports #-} | ||
{-# OPTIONS_GHC -Wno-dodgy-exports #-} | ||
|
||
module Pos.Chain.Block.Main | ||
( module Pos.Chain.Block.Main.Instances | ||
, module Pos.Chain.Block.Main.Types | ||
) where | ||
|
||
import Pos.Chain.Block.Main.Instances | ||
import Pos.Chain.Block.Main.Types |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Pos.Chain.Block.Union | ||
( module Pos.Chain.Block.Union.ComponentBlock | ||
, module Pos.Chain.Block.Union.Types | ||
) where | ||
|
||
import Pos.Chain.Block.Union.ComponentBlock | ||
import Pos.Chain.Block.Union.Types |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this just a redundant constraint or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old code base used these to side step orphan instance problems.