| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Ouroboros.Consensus.Leios.NotifyLog
Description
What the node relays to its downstream peers over LeiosNotify.
The node keeps one log of notifications, in the order it appended them, and
every LeiosNotify server reads that log through its own NotifyCursor. So a
notification is stored once however many peers it goes to, and a peer that
requests slowly merely lags behind in the log, rather than piling up a queue
of its own.
Whoever appends a notification says until when it is worth relaying; the
pruner drops it then, and the log does not take one it was pruned past
already. So the node relays none longer than notifyLogPruneCadence after
that. A peer that connects
late starts at the log's oldest notification, so it still receives
everything worth relaying, and a notification is never worth relaying longer
than the announcement it is about, so a peer always receives the
announcement first. A cursor that falls behind pruning merely skips what was
pruned.
Synopsis
- data Notification blk
- = NotifyAnnouncement !(AnnouncingHeader blk)
- | NotifyVote !LeiosVote
- data NotifyCursor
- data NotifyLog (m ∷ Type → Type) blk
- appendNotifyLog ∷ ∀ (m ∷ Type → Type) blk. IOLike m ⇒ NotifyLog m blk → Notification blk → RelativeTime → STM m ()
- newNotifyLog ∷ (IOLike m, NoThunks (Header blk)) ⇒ m (NotifyLog m blk)
- nextNotifyLog ∷ ∀ (m ∷ Type → Type) blk. IOLike m ⇒ NotifyLog m blk → NotifyCursor → STM m (Notification blk, NotifyCursor)
- notifyLogPruneCadence ∷ NominalDiffTime
- notifyLogPruner ∷ IOLike m ⇒ SystemTime m → NotifyLog m blk → m Void
- notifyLogStart ∷ NotifyCursor
- pruneNotifyLog ∷ ∀ (m ∷ Type → Type) blk. IOLike m ⇒ NotifyLog m blk → RelativeTime → STM m ()
Documentation
data Notification blk Source #
A notification the node relays.
Constructors
| NotifyAnnouncement !(AnnouncingHeader blk) | |
| NotifyVote !LeiosVote |
Instances
data NotifyCursor Source #
A position in the log, which only ever grows.
Instances
| Eq NotifyCursor Source # | |
Defined in Ouroboros.Consensus.Leios.NotifyLog | |
| Ord NotifyCursor Source # | |
Defined in Ouroboros.Consensus.Leios.NotifyLog Methods compare ∷ NotifyCursor → NotifyCursor → Ordering # (<) ∷ NotifyCursor → NotifyCursor → Bool # (<=) ∷ NotifyCursor → NotifyCursor → Bool # (>) ∷ NotifyCursor → NotifyCursor → Bool # (>=) ∷ NotifyCursor → NotifyCursor → Bool # max ∷ NotifyCursor → NotifyCursor → NotifyCursor # min ∷ NotifyCursor → NotifyCursor → NotifyCursor # | |
| Show NotifyCursor Source # | |
Defined in Ouroboros.Consensus.Leios.NotifyLog Methods showsPrec ∷ Int → NotifyCursor → ShowS # show ∷ NotifyCursor → String # showList ∷ [NotifyCursor] → ShowS # | |
| NoThunks NotifyCursor Source # | |
Defined in Ouroboros.Consensus.Leios.NotifyLog | |
appendNotifyLog ∷ ∀ (m ∷ Type → Type) blk. IOLike m ⇒ NotifyLog m blk → Notification blk → RelativeTime → STM m () Source #
Append a notification worth relaying until the given time, unless the log was pruned past it already.
After that time, the notification is of no use to a downstream peer: a vote's deadline, or when an announcement is too old to relay. Either leaves a grace, for transmission and queueing, before the peer would reject it.
nextNotifyLog ∷ ∀ (m ∷ Type → Type) blk. IOLike m ⇒ NotifyLog m blk → NotifyCursor → STM m (Notification blk, NotifyCursor) Source #
The first notification at or after the cursor, and the cursor just past it.
Retries until there is such a notification.
notifyLogPruneCadence ∷ NominalDiffTime Source #
How often the log is pruned, so how long after it stops being worth relaying the node may still relay a notification. It must stay far below the grace a downstream peer gives before it rejects one.
notifyLogPruner ∷ IOLike m ⇒ SystemTime m → NotifyLog m blk → m Void Source #
Prune the log every notifyLogPruneCadence.
notifyLogStart ∷ NotifyCursor Source #
Where a downstream peer starts reading: before every notification, including the ones already pruned.
pruneNotifyLog ∷ ∀ (m ∷ Type → Type) blk. IOLike m ⇒ NotifyLog m blk → RelativeTime → STM m () Source #
Prune every notification no longer worth relaying at the given time.
Leaves the notifications untouched if there is none, so as not to wake every server reading them.