Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype ConnMap peerAddr a = ConnMap {
- getConnMap :: Map peerAddr (Map (LocalAddr peerAddr) a)
- data LocalAddr peerAddr
- = UnknownLocalAddr
- | LocalAddr peerAddr
- toList :: ConnMap m a -> [a]
- toMap :: Ord peerAddr => ConnMap peerAddr a -> Map (ConnectionId peerAddr) a
- empty :: ConnMap peerAddr a
- insert :: Ord peerAddr => ConnectionId peerAddr -> a -> ConnMap peerAddr a -> ConnMap peerAddr a
- insertUnknownLocalAddr :: Ord peerAddr => peerAddr -> a -> ConnMap peerAddr a -> ConnMap peerAddr a
- delete :: Ord peerAddr => ConnectionId peerAddr -> ConnMap peerAddr a -> ConnMap peerAddr a
- deleteAtRemoteAddr :: (Ord peerAddr, Eq a) => peerAddr -> a -> ConnMap peerAddr a -> ConnMap peerAddr a
- lookup :: Ord peerAddr => ConnectionId peerAddr -> ConnMap peerAddr a -> Maybe a
- lookupByRemoteAddr :: forall rnd peerAddr a. (Ord peerAddr, RandomGen rnd) => rnd -> peerAddr -> ConnMap peerAddr a -> Maybe a
- updateLocalAddr :: Ord peerAddr => ConnectionId peerAddr -> ConnMap peerAddr a -> (Bool, ConnMap peerAddr a)
- traverseMaybe :: Applicative f => (a -> f (Maybe b)) -> ConnMap peerAddr a -> f [b]
Documentation
newtype ConnMap peerAddr a Source #
The outer map keys are remote addresses, the internal ones are local addresses.
ConnMap | |
|
Instances
Functor (ConnMap peerAddr) Source # | |
Foldable (ConnMap peerAddr) Source # | |
Defined in Ouroboros.Network.ConnectionManager.ConnMap fold :: Monoid m => ConnMap peerAddr m -> m # foldMap :: Monoid m => (a -> m) -> ConnMap peerAddr a -> m # foldMap' :: Monoid m => (a -> m) -> ConnMap peerAddr a -> m # foldr :: (a -> b -> b) -> b -> ConnMap peerAddr a -> b # foldr' :: (a -> b -> b) -> b -> ConnMap peerAddr a -> b # foldl :: (b -> a -> b) -> b -> ConnMap peerAddr a -> b # foldl' :: (b -> a -> b) -> b -> ConnMap peerAddr a -> b # foldr1 :: (a -> a -> a) -> ConnMap peerAddr a -> a # foldl1 :: (a -> a -> a) -> ConnMap peerAddr a -> a # toList :: ConnMap peerAddr a -> [a] # null :: ConnMap peerAddr a -> Bool # length :: ConnMap peerAddr a -> Int # elem :: Eq a => a -> ConnMap peerAddr a -> Bool # maximum :: Ord a => ConnMap peerAddr a -> a # minimum :: Ord a => ConnMap peerAddr a -> a # | |
Traversable (ConnMap peerAddr) Source # | |
Defined in Ouroboros.Network.ConnectionManager.ConnMap traverse :: Applicative f => (a -> f b) -> ConnMap peerAddr a -> f (ConnMap peerAddr b) # sequenceA :: Applicative f => ConnMap peerAddr (f a) -> f (ConnMap peerAddr a) # mapM :: Monad m => (a -> m b) -> ConnMap peerAddr a -> m (ConnMap peerAddr b) # sequence :: Monad m => ConnMap peerAddr (m a) -> m (ConnMap peerAddr a) # | |
(Show peerAddr, Show a) => Show (ConnMap peerAddr a) Source # | |
data LocalAddr peerAddr Source #
UnknownLocalAddr | A reserved slot for an outbound connection which is being created. The
outbound connection must be in the |
LocalAddr peerAddr | All connections which are not in the |
Instances
Show peerAddr => Show (LocalAddr peerAddr) Source # | |
Eq peerAddr => Eq (LocalAddr peerAddr) Source # | |
Ord peerAddr => Ord (LocalAddr peerAddr) Source # | |
Defined in Ouroboros.Network.ConnectionManager.ConnMap compare :: LocalAddr peerAddr -> LocalAddr peerAddr -> Ordering # (<) :: LocalAddr peerAddr -> LocalAddr peerAddr -> Bool # (<=) :: LocalAddr peerAddr -> LocalAddr peerAddr -> Bool # (>) :: LocalAddr peerAddr -> LocalAddr peerAddr -> Bool # (>=) :: LocalAddr peerAddr -> LocalAddr peerAddr -> Bool # max :: LocalAddr peerAddr -> LocalAddr peerAddr -> LocalAddr peerAddr # min :: LocalAddr peerAddr -> LocalAddr peerAddr -> LocalAddr peerAddr # |
toMap :: Ord peerAddr => ConnMap peerAddr a -> Map (ConnectionId peerAddr) a Source #
Create a map of all connections with a known ConnectionId
.
insert :: Ord peerAddr => ConnectionId peerAddr -> a -> ConnMap peerAddr a -> ConnMap peerAddr a Source #
insertUnknownLocalAddr :: Ord peerAddr => peerAddr -> a -> ConnMap peerAddr a -> ConnMap peerAddr a Source #
delete :: Ord peerAddr => ConnectionId peerAddr -> ConnMap peerAddr a -> ConnMap peerAddr a Source #
:: forall rnd peerAddr a. (Ord peerAddr, RandomGen rnd) | |
=> rnd | a fresh |
-> peerAddr | remote address |
-> ConnMap peerAddr a | |
-> Maybe a |
Find a random entry for a given remote address.
NOTE: the outbound governor will only ask for a connection to a peer if it
doesn't have one (and one isn't being created). This property, simplifies
lookupOutbound
: we can pick (randomly) one of the connections to the
remote peer. When the outbound governor is asking, likely all of the
connections are in an inbound state. The outbound governor will has a grace
period after demoting a peer, so a race (when a is being demoted and
promoted at the same time) is unlikely.
:: Ord peerAddr | |
=> ConnectionId peerAddr | |
-> ConnMap peerAddr a | |
-> (Bool, ConnMap peerAddr a) | Return |
Promote UnknownLocalAddr
to LocalAddr
.
traverseMaybe :: Applicative f => (a -> f (Maybe b)) -> ConnMap peerAddr a -> f [b] Source #