Skip to content

Commit

Permalink
Style
Browse files Browse the repository at this point in the history
  • Loading branch information
bolt12 committed Mar 3, 2023
1 parent 6f9d983 commit 9ecb003
Show file tree
Hide file tree
Showing 22 changed files with 43 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import Ouroboros.Network.CodecCBORTerm
import Ouroboros.Network.Handshake.Acceptable (Accept (..),
Acceptable (..))
import Ouroboros.Network.Magic
import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))


-- | Enumeration of node to node protocol versions.
Expand Down
5 changes: 2 additions & 3 deletions ouroboros-network-protocols/test-cddl/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ import Ouroboros.Network.Protocol.TxSubmission2.Type (TxSubmission2)
import qualified Ouroboros.Network.Protocol.TxSubmission2.Type as TxSubmission2

import Network.Socket (SockAddr (..))
import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..), decodeRemoteAddress,
encodeRemoteAddress)
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..),
decodeRemoteAddress, encodeRemoteAddress)
import Ouroboros.Network.Protocol.PeerSharing.Codec (codecPeerSharing)
import Ouroboros.Network.Protocol.PeerSharing.Test ()
import Ouroboros.Network.Protocol.PeerSharing.Type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ import Ouroboros.Network.Magic
import Ouroboros.Network.NodeToClient.Version
import Ouroboros.Network.NodeToNode.Version

import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))
import Test.QuickCheck
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.QuickCheck (testProperty)
Expand Down
3 changes: 1 addition & 2 deletions ouroboros-network/src/Ouroboros/Network/NodeToNode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ import Ouroboros.Network.PeerSelection.Governor.Types
(PeerSelectionTargets (..))
import Ouroboros.Network.PeerSelection.PeerAdvertise
(PeerAdvertise (..))
import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))
import Ouroboros.Network.PeerSelection.RootPeersDNS
(DomainAccessPoint (..))
import Ouroboros.Network.Protocol.Handshake.Codec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ deletePeers :: Ord peeraddr
=> Set peeraddr
-> EstablishedPeers peeraddr peerconn
-> EstablishedPeers peeraddr peerconn
deletePeers peeraddrs es@EstablishedPeers { allPeers
, availableForPeerShare
, nextPeerShareTimes
, nextActivateTimes
deletePeers peeraddrs es@EstablishedPeers { allPeers,
availableForPeerShare,
nextPeerShareTimes,
nextActivateTimes
} =
es { allPeers = Map.withoutKeys allPeers peeraddrs,
availableForPeerShare = Set.difference availableForPeerShare peeraddrs,
Expand All @@ -226,10 +226,10 @@ setCurrentTime now ep@EstablishedPeers { nextPeerShareTimes
, nextActivateTimes
}
-- Efficient check for the common case of there being nothing to do:
| Just (Min t) <- (f <$> PSQ.minView nextPeerShareTimes)
<> (f <$> PSQ.minView nextActivateTimes)
, t > now
= ep
| Just (Min t) <- (f <$> PSQ.minView nextPeerShareTimes)
<> (f <$> PSQ.minView nextActivateTimes)
, t > now
= ep
where
f (_,t,_,_) = Min t

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import Ouroboros.Network.PeerSelection.LedgerPeers (IsLedgerPeer (..))
import qualified Ouroboros.Network.PeerSelection.LocalRootPeers as LocalRootPeers
import Ouroboros.Network.PeerSelection.PeerAdvertise
(PeerAdvertise (..))
import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))
import Ouroboros.Network.Protocol.PeerSharing.Type (PeerSharingAmount)


Expand Down Expand Up @@ -77,9 +76,9 @@ belowTarget actions
= Guarded Nothing $ do
-- Max selected should be <= numPeerShareReqsPossible
selectedForPeerShare <- pickPeers st
policyPickKnownPeersForPeerShare
canAsk
numPeerShareReqsPossible
policyPickKnownPeersForPeerShare
canAsk
numPeerShareReqsPossible

let -- Should be <= numPeerShareReqsPossible
numPeerShareReqs = Set.size selectedForPeerShare
Expand Down Expand Up @@ -143,12 +142,12 @@ jobPeerShare PeerSelectionActions{requestPeerShare}
handler :: [peeraddr] -> SomeException -> m (Completion m peeraddr peerconn)
handler peers e = return $
Completion $ \st _ ->
Decision { decisionTrace = [TracePeerShareResults [ (p, Left e) | p <- peers ]]
, decisionState =
Decision { decisionTrace = [TracePeerShareResults [ (p, Left e) | p <- peers ]],
decisionState =
st { inProgressPeerShareReqs = inProgressPeerShareReqs st
- length peers
}
, decisionJobs = []
},
decisionJobs = []
}

jobPhase1 :: [(PeerSharingAmount, peeraddr)] -> m (Completion m peeraddr peerconn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ import Ouroboros.Network.PeerSelection.Governor.Types hiding
import qualified Ouroboros.Network.PeerSelection.KnownPeers as KnownPeers
import Ouroboros.Network.PeerSelection.LedgerPeers (IsLedgerPeer (..))
import qualified Ouroboros.Network.PeerSelection.LocalRootPeers as LocalRootPeers
import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))
import Ouroboros.Network.PeerSelection.Types


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import Control.Monad.Class.MonadTime
import Ouroboros.Network.PeerSelection.Governor.Types
import qualified Ouroboros.Network.PeerSelection.KnownPeers as KnownPeers
import qualified Ouroboros.Network.PeerSelection.LocalRootPeers as LocalRootPeers
import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))


--------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ import qualified Ouroboros.Network.PeerSelection.KnownPeers as KnownPeers
import Ouroboros.Network.PeerSelection.LedgerPeers (IsLedgerPeer)
import Ouroboros.Network.PeerSelection.LocalRootPeers (LocalRootPeers)
import qualified Ouroboros.Network.PeerSelection.LocalRootPeers as LocalRootPeers
import Ouroboros.Network.PeerSelection.PeerAdvertise
(PeerAdvertise)
import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise)
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing)
import Ouroboros.Network.PeerSelection.Types (PeerSource (..),
PeerStatus (PeerHot, PeerWarm))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ import Control.Exception (assert)
import Control.Monad.Class.MonadTime

import Ouroboros.Network.PeerSelection.LedgerPeers (IsLedgerPeer (..))
import Ouroboros.Network.PeerSelection.PeerAdvertise
(PeerAdvertise)
import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..), combinePeerInformation)
import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise)
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..),
combinePeerInformation)


-------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import qualified Data.Map.Strict as Map
import Data.Set (Set)
import qualified Data.Set as Set

import Ouroboros.Network.PeerSelection.PeerAdvertise
(PeerAdvertise)
import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise)


---------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ import qualified Data.IP as IP
import qualified Network.DNS as DNS
import qualified Network.Socket as Socket

import Ouroboros.Network.PeerSelection.PeerAdvertise
(PeerAdvertise)
import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise)
import Ouroboros.Network.PeerSelection.RelayAccessPoint
import Ouroboros.Network.PeerSelection.RootPeersDNS.DNSActions
(DNSActions (..), DNSorIOError (..), LookupReqs (..),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ import Simulation.Network.Snocket (AddressType (..), FD)
import Control.Monad.Class.MonadMVar (MonadMVar)
import Ouroboros.Network.PeerSelection.PeerAdvertise
(PeerAdvertise (..))
import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))
import Ouroboros.Network.PeerSharing
(PeerSharingRegistry (PeerSharingRegistry))
import qualified Test.Ouroboros.Network.Diffusion.Node.MiniProtocols as Node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import Ouroboros.Network.CodecCBORTerm
import Ouroboros.Network.Magic
import Ouroboros.Network.NodeToNode.Version

import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))
import Test.QuickCheck
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.QuickCheck (testProperty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ import Control.Concurrent.Class.MonadSTM.Strict (newTVarIO)
import Ouroboros.Network.PeerSelection.LedgerPeers (IsLedgerPeer (..))
import Ouroboros.Network.PeerSelection.PeerAdvertise
(PeerAdvertise (..))
import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))
import Ouroboros.Network.Protocol.PeerSharing.Type
(PeerSharingResult (..))
import Test.QuickCheck
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import Ouroboros.Network.PeerSelection.RootPeersDNS
import qualified Data.IP as IP
import Ouroboros.Network.PeerSelection.PeerAdvertise
(PeerAdvertise (..))
import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))
import Ouroboros.Network.Testing.Utils (prop_shrink_nonequal,
prop_shrink_valid)
import Test.QuickCheck
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import Ouroboros.Network.PeerSelection.RootPeersDNS
(DomainAccessPoint (..), RelayAccessPoint (..))
import Test.Ouroboros.Network.PeerSelection.Instances ()

import Ouroboros.Network.PeerSelection.PeerAdvertise
(PeerAdvertise)
import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise)
import Test.QuickCheck
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.QuickCheck (testProperty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import Ouroboros.Network.Testing.Utils (prop_shrink_nonequal,
import Test.Ouroboros.Network.PeerSelection.Instances


import Ouroboros.Network.PeerSelection.PeerAdvertise
(PeerAdvertise)
import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise)
import Test.QuickCheck
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.QuickCheck (testProperty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ import Test.Ouroboros.Network.PeerSelection.PeerGraph
import Test.Ouroboros.Network.ShrinkCarefully

import Ouroboros.Network.PeerSelection.LedgerPeers (IsLedgerPeer)
import Ouroboros.Network.PeerSelection.PeerAdvertise
(PeerAdvertise)
import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..))
import Ouroboros.Network.PeerSelection.PeerAdvertise (PeerAdvertise)
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))
import Ouroboros.Network.PeerSelection.Types (PeerStatus (..))
import Ouroboros.Network.Protocol.PeerSharing.Type (PeerSharingAmount,
PeerSharingResult (..))
Expand Down
3 changes: 1 addition & 2 deletions ouroboros-network/test/Test/Ouroboros/Network/Testnet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ import Test.Tasty.QuickCheck (testProperty)
import Ouroboros.Network.NodeToNode (DiffusionMode (..))
import Ouroboros.Network.PeerSelection.PeerAdvertise
(PeerAdvertise (..))
import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))
import TestLib.ConnectionManager (abstractStateIsFinalTransition,
connectionManagerTraceMap, validTransitionMap,
verifyAbstractTransition, verifyAbstractTransitionOrder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ import qualified Test.Ouroboros.Network.PeerSelection.RootPeersDNS as PeerSelect
import Test.Ouroboros.Network.PeerSelection.RootPeersDNS
(DNSLookupDelay (..), DNSTimeout (..))

import Test.QuickCheck
import Control.Monad.Class.MonadMVar (MonadMVar)
import Ouroboros.Network.PeerSelection.PeerAdvertise
(PeerAdvertise (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing)
import Ouroboros.Network.Protocol.PeerSharing.Codec
(byteLimitsPeerSharing, timeLimitsPeerSharing)
import Test.QuickCheck

-- | Diffusion Simulator Arguments
--
Expand Down Expand Up @@ -158,15 +158,15 @@ data NodeArgs =
, naDiffusionMode :: DiffusionMode
, naMbTime :: Maybe DiffTime
-- ^ 'LimitsAndTimeouts' argument
, naRelays :: Map RelayAccessPoint PeerAdvertise
, naRelays :: Map RelayAccessPoint PeerAdvertise
-- ^ 'Interfaces' relays auxiliary value
, naDomainMap :: Map Domain [IP]
-- ^ 'Interfaces' 'iDomainMap' value
, naAddr :: NtNAddr
-- ^ 'Arguments' 'aIPAddress' value
, naPeerSharing :: PeerSharing
, naPeerSharing :: PeerSharing
-- ^ 'Arguments' 'aIPAddress' value
, naLocalRootPeers :: [(Int, Map RelayAccessPoint PeerAdvertise)]
, naLocalRootPeers :: [(Int, Map RelayAccessPoint PeerAdvertise)]
-- ^ 'Arguments' 'LocalRootPeers' values
, naLocalSelectionTargets :: PeerSelectionTargets
-- ^ 'Arguments' 'aLocalSelectionTargets' value
Expand Down
3 changes: 1 addition & 2 deletions ouroboros-network/test/Test/Socket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ import Ouroboros.Network.Util.ShowProxy

import Test.ChainGenerators (TestBlockChainAndUpdates (..))

import Ouroboros.Network.PeerSelection.PeerSharing
(PeerSharing (..))
import Ouroboros.Network.PeerSelection.PeerSharing (PeerSharing (..))
import Test.QuickCheck
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.QuickCheck (testProperty)
Expand Down

0 comments on commit 9ecb003

Please sign in to comment.