-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better Point type factoring, again #706
Changes from 3 commits
7b35a6d
4363346
53a9dad
7c4e456
7c679aa
3648d99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,11 +38,13 @@ import Control.Monad.Class.MonadSTM | |
import Control.Monad.Class.MonadThrow | ||
|
||
import Ouroboros.Network.AnchoredFragment (AnchoredFragment) | ||
import Ouroboros.Network.Block (ChainHash (..), ChainUpdate, | ||
HasHeader (..), HeaderHash, SlotNo, StandardHash) | ||
import Ouroboros.Network.Block (ChainUpdate, HasHeader (..), | ||
HeaderHash, SlotNo, StandardHash) | ||
import Ouroboros.Network.Chain (Chain (..), Point (..), genesisPoint) | ||
import qualified Ouroboros.Network.Chain as Chain | ||
import Ouroboros.Network.ChainProducerState (ReaderId) | ||
import Ouroboros.Network.Point (WithOrigin (..)) | ||
import qualified Ouroboros.Network.Point as Point (Block (..)) | ||
|
||
import Ouroboros.Consensus.Block (GetHeader (..)) | ||
import Ouroboros.Consensus.Ledger.Extended | ||
|
@@ -319,17 +321,30 @@ data UnknownRange blk = | |
-- | ||
-- > StreamFromExclusive (Point { pointSlot = SlotNo 3 , .. } | ||
-- > StreamToInclusive (Point { pointSlot = SlotNo 3 , .. } | ||
-- | ||
-- FIXME StreamFrom and StreamTo can be refined to not admit origin points | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I will do that when this is merged. |
||
-- in cases where it doesn't make sense. | ||
validBounds :: StreamFrom blk -> StreamTo blk -> Bool | ||
validBounds from to = case from of | ||
StreamFromInclusive (Point { pointHash = GenesisHash }) -> False | ||
|
||
StreamFromInclusive (Point { pointSlot = sfrom }) -> case to of | ||
StreamToInclusive (Point { pointSlot = sto }) -> sfrom <= sto | ||
StreamToExclusive (Point { pointSlot = sto }) -> sfrom < sto | ||
StreamFromInclusive (Point Origin) -> False | ||
|
||
StreamFromExclusive (Point Origin) -> case to of | ||
StreamToInclusive (Point Origin) -> False | ||
StreamToExclusive (Point Origin) -> False | ||
_ -> True | ||
|
||
StreamFromInclusive (Point (At (Point.Block { Point.blockPointSlot = sfrom }))) -> case to of | ||
mrBliss marked this conversation as resolved.
Show resolved
Hide resolved
|
||
StreamToInclusive (Point Origin) -> False | ||
StreamToExclusive (Point Origin) -> False | ||
StreamToInclusive (Point (At (Point.Block { Point.blockPointSlot = sto }))) -> sfrom <= sto | ||
StreamToExclusive (Point (At (Point.Block { Point.blockPointSlot = sto }))) -> sfrom < sto | ||
|
||
StreamFromExclusive (Point { pointSlot = sfrom }) -> case to of | ||
StreamToInclusive (Point { pointSlot = sto }) -> sfrom < sto | ||
StreamToExclusive (Point { pointSlot = sto }) -> sfrom < sto | ||
StreamFromExclusive (Point (At (Point.Block { Point.blockPointSlot = sfrom }))) -> case to of | ||
StreamToInclusive (Point Origin) -> False | ||
StreamToExclusive (Point Origin) -> False | ||
StreamToInclusive (Point (At (Point.Block { Point.blockPointSlot = sto }))) -> sfrom < sto | ||
avieth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
StreamToExclusive (Point (At (Point.Block { Point.blockPointSlot = sto }))) -> sfrom < sto | ||
|
||
-- | Stream all blocks from the current chain. | ||
-- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module Ouroboros.Network.Point | ||
( WithOrigin (..) | ||
, Block (..) | ||
, origin | ||
, at | ||
, block | ||
) where | ||
|
||
data WithOrigin t = Origin | At t | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why Origin instead of Genesis? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, fine for me. (What about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might have places in haddock where we refer to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
deriving (Eq, Ord, Show) | ||
avieth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
instance Functor WithOrigin where | ||
fmap _ Origin = Origin | ||
fmap f (At t) = At (f t) | ||
|
||
data Block slot hash = Block | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about calling this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this module it is clear that it is a point since (apart from the type, the module is named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see now it is imported qualified in other places, just dropping a comment at the top might be useful. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My intuition is also for |
||
{ blockPointSlot :: !slot | ||
, blockPointHash :: !hash | ||
} | ||
deriving (Eq, Ord, Show) | ||
|
||
at :: t -> WithOrigin t | ||
at = At | ||
|
||
origin :: WithOrigin t | ||
origin = Origin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it worth to duplicate the api? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not clear it's worth using functions rather than constructors directly. |
||
|
||
block :: slot -> hash -> WithOrigin (Block slot hash) | ||
block slot hash = at (Block slot hash) |
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.
Apparently a new build of iohk-monitoring has been brought in recently, and bryon-proxy wasn't updated. How did this pass CI?
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.
@jbgi could you take a look why this slipped through CI