module Network.ZGossip.Types (
    ZGossipState(..)
  , emptyGossipState
  , cvtPub) where

import qualified Data.Map as M
import qualified Data.Set as S

import Data.ZGossip

data ZGossipState = ZGossipState {
    ZGossipState -> Set Peer
gossipPeers   :: S.Set Peer
  , ZGossipState -> Map Peer (Peer, TTL)
gossipPairs   :: M.Map Key (Value, TTL)
} deriving (TTL -> ZGossipState -> ShowS
[ZGossipState] -> ShowS
ZGossipState -> String
(TTL -> ZGossipState -> ShowS)
-> (ZGossipState -> String)
-> ([ZGossipState] -> ShowS)
-> Show ZGossipState
forall a.
(TTL -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ZGossipState] -> ShowS
$cshowList :: [ZGossipState] -> ShowS
show :: ZGossipState -> String
$cshow :: ZGossipState -> String
showsPrec :: TTL -> ZGossipState -> ShowS
$cshowsPrec :: TTL -> ZGossipState -> ShowS
Show)

emptyGossipState :: ZGossipState
emptyGossipState :: ZGossipState
emptyGossipState = Set Peer -> Map Peer (Peer, TTL) -> ZGossipState
ZGossipState Set Peer
forall a. Set a
S.empty Map Peer (Peer, TTL)
forall k a. Map k a
M.empty

cvtPub :: (Key, (Value, TTL)) -> ZGSCmd
cvtPub :: (Peer, (Peer, TTL)) -> ZGSCmd
cvtPub (Peer
k, (Peer
v, TTL
ttl)) = Peer -> Peer -> TTL -> ZGSCmd
Publish Peer
k Peer
v TTL
ttl