Skip to content

Commit

Permalink
revert initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
darshankabariya committed Jul 10, 2024
1 parent 7520eca commit 8714beb
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
2 changes: 0 additions & 2 deletions waku/node/peer_manager/peer_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,7 @@ proc connectRelay*(

waku_peers_dials.inc(labelValues = ["successful"])
waku_node_conns_initiated.inc(labelValues = [source])

pm.peerStore[NumberFailedConnBook][peerId] = 0
pm.peerStore[LastSuccessfulConnBook][peerId] = Moment.init(getTime().toUnix, Second)

return true

Expand Down
11 changes: 2 additions & 9 deletions waku/node/peer_manager/waku_peer_store.nim
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{.push raises: [].}

import
std/[tables, sequtils, sets, options, strutils, times, random, math],
std/[tables, sequtils, sets, options, strutils],
chronos,
chronos/timer,
eth/p2p/discoveryv5/enr,
libp2p/builders,
libp2p/peerstore
Expand All @@ -24,9 +23,6 @@ type
# Last failed connection attemp timestamp
LastFailedConnBook* = ref object of PeerBook[Moment]

# Last Successful connection attemp timestamp
LastSuccessfulConnBook* = ref object of PeerBook[Moment]

# Failed connection attempts
NumberFailedConnBook* = ref object of PeerBook[int]

Expand Down Expand Up @@ -72,7 +68,6 @@ proc get*(peerStore: PeerStore, peerId: PeerID): RemotePeerInfo =
origin: peerStore[SourceBook][peerId],
direction: peerStore[DirectionBook][peerId],
lastFailedConn: peerStore[LastFailedConnBook][peerId],
lastSuccessfulConn: peerStore[LastSuccessfulConnBook][peerId],
numberFailedConn: peerStore[NumberFailedConnBook][peerId],
)

Expand Down Expand Up @@ -145,10 +140,8 @@ proc getPeersByProtocol*(peerStore: PeerStore, proto: string): seq[RemotePeerInf
return peerStore.peers.filterIt(it.protocols.contains(proto))

proc getReachablePeers*(peerStore: PeerStore): seq[RemotePeerInfo] =
let threshold = Moment.fromNow(millis(-3*60*60*1000))
return peerStore.peers.filterIt(
(it.connectedness == CanConnect or it.connectedness == Connected) and
(it.lastSuccessfulConn > threshold)
(it.connectedness == CanConnect or it.connectedness == Connected)
)

proc getPeersByShard*(
Expand Down
1 change: 0 additions & 1 deletion waku/waku_core/peers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ type RemotePeerInfo* = ref object
origin*: PeerOrigin
direction*: PeerDirection
lastFailedConn*: Moment
lastSuccessfulConn*: Moment
numberFailedConn*: int

func `$`*(remotePeerInfo: RemotePeerInfo): string =
Expand Down

0 comments on commit 8714beb

Please sign in to comment.