-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4555 from IntersectMBO/bolt12/4530
Bootstrap Peers Implementation
- Loading branch information
Showing
44 changed files
with
2,895 additions
and
1,037 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
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
44 changes: 44 additions & 0 deletions
44
ouroboros-network-api/src/Ouroboros/Network/PeerSelection/Bootstrap.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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Ouroboros.Network.PeerSelection.Bootstrap | ||
( UseBootstrapPeers (..) | ||
, isBootstrapPeersEnabled | ||
, requiresBootstrapPeers | ||
, isNodeAbleToMakeProgress | ||
) where | ||
|
||
import GHC.Generics (Generic) | ||
import Ouroboros.Network.PeerSelection.LedgerPeers.Type | ||
(LedgerStateJudgement (..)) | ||
import Ouroboros.Network.PeerSelection.RelayAccessPoint | ||
(RelayAccessPoint) | ||
|
||
data UseBootstrapPeers = DontUseBootstrapPeers | ||
| UseBootstrapPeers [RelayAccessPoint] | ||
deriving (Eq, Show, Ord, Generic) | ||
|
||
isBootstrapPeersEnabled :: UseBootstrapPeers -> Bool | ||
isBootstrapPeersEnabled DontUseBootstrapPeers = False | ||
isBootstrapPeersEnabled _ = True | ||
|
||
-- | Determines if the system is in a sensitive state based on bootstrap peer | ||
-- usage and ledger state. | ||
-- | ||
-- * When bootstrap peers are not in use, the system is considered to never be | ||
-- in a sensitive state. | ||
-- * When bootstrap peers are in use and the ledger is in 'YoungEnough' state, | ||
-- the system is not in a sensitive state. | ||
-- * When bootstrap peers are in use and the ledger is in 'TooOld' state, | ||
-- the system is considered to be in a sensitive state. | ||
requiresBootstrapPeers :: UseBootstrapPeers -> LedgerStateJudgement -> Bool | ||
requiresBootstrapPeers ubp lsj = | ||
isBootstrapPeersEnabled ubp && lsj == TooOld | ||
|
||
-- | A node is able to make progress either if it isn't in a sensitive state | ||
-- _or_ if it is in a sensitive state and has reached a clean state from which | ||
-- it now only uses trustable peers | ||
-- | ||
isNodeAbleToMakeProgress :: UseBootstrapPeers -> LedgerStateJudgement -> Bool -> Bool | ||
isNodeAbleToMakeProgress ubp lsj hasOnlyBootstrapPeers = | ||
not (requiresBootstrapPeers ubp lsj) || hasOnlyBootstrapPeers |
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
15 changes: 15 additions & 0 deletions
15
ouroboros-network-api/src/Ouroboros/Network/PeerSelection/PeerTrustable.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{-# LANGUAGE DeriveGeneric #-} | ||
|
||
module Ouroboros.Network.PeerSelection.PeerTrustable (PeerTrustable (..)) where | ||
|
||
import GHC.Generics (Generic) | ||
|
||
-- | Is this Peer trustable as a bootstrap peer? | ||
-- | ||
-- This trustability flag is used on local root peers (pre-genesis) to | ||
-- distinguish which locally configured peer is considered safe to trust for | ||
-- bootstrap purposes | ||
-- | ||
data PeerTrustable = IsTrustable | ||
| IsNotTrustable | ||
deriving (Eq, Show, Ord, Generic) |
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
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
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
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
Oops, something went wrong.