gini-network-0.1.0.0

Safe HaskellNone
LanguageHaskell2010

Gini.Network.Peers

Contents

Description

Peers management

Synopsis

Initialization

empty :: PeersState #

Empty peers state

Known peers

addKnownPeer :: (HasPeersState env, HasCacheStorage env) => Peer -> UTCTime -> Account -> RIO env () #

Add (or update) a new known peer

updateKnownPeers :: (HasCacheStorage env, HasPeersState env) => UTCTime -> RIO env () #

Remove peers from database that haven't been heard from in too long and update the in-memory structure.

updateLastContact :: MonadIO m => Peer -> UTCTime -> ReaderT SqlBackend m () #

Update the last time a peer has contacted us.

KeepAlive

keepAlivePeriod :: NominalDiffTime #

How often to send keepalives to a given peer

mkKeepAliveMessages :: (HasCoreConfig env, HasPeersState env) => UTCTime -> Set Peer -> ReaderT env STM [(Peer, MessageBody)] #

Create KeepAlive messages for the given peers. Only peers that have not already recently been sent a KeepAlive will have messages.

trimSentKeepAlives :: HasPeersState env => UTCTime -> ReaderT env STM () #

Remove old records of sent keepalives.

Node ID handshake

peerNodeIdHandshakeQuery :: (HasCryptoConfig env, HasPeersState env) => Peer -> UTCTime -> ReaderT env STM (Maybe Cookie) #

If the received from peer is unknown and there are not already too many in-progress handshakes for the host, returns a node ID query handshake cookie to send to it.

periodicallyCleanupNodeIdHandshakes :: HasPeersState env => RIO env () #

Run background process to clean up pending node ID handshakes

verifyPeerNodeIdHandshakeCookie :: HasPeersState env => Peer -> Account -> Signature -> RIO env Bool #

Verify a peer's node ID handshake response cookie

Types