Skip to content

Commit 482cce2

Browse files
authored
refactor(Identify): remove peerId argument form IdentifyPushHandler (#2606)
1 parent ab9e1a1 commit 482cce2

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

libp2p/protocols/identify.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ type
7171
observedAddrManager*: ObservedAddrManager
7272

7373
IdentifyPushHandler* =
74-
proc(peer: PeerId, newInfo: IdentifyInfo): Future[void] {.gcsafe, raises: [].}
74+
proc(newInfo: IdentifyInfo): Future[void] {.gcsafe, raises: [].}
7575

7676
IdentifyPush* = ref object of LPProtocol
7777
identifyHandler: IdentifyPushHandler
@@ -239,7 +239,7 @@ proc init*(p: IdentifyPush) =
239239
if not handler.isNil:
240240
trace "triggering peer event", peerInfo = stream.peerId
241241
try:
242-
await handler(stream.peerId, makeIdentifyInfo(peerId, identifyMsg))
242+
await handler(makeIdentifyInfo(peerId, identifyMsg))
243243
except CancelledError as e:
244244
raise e
245245
except CatchableError as e:

libp2p/services/identify_pusher.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ method setup*(p: IdentifyPusher, switch: Switch) {.raises: [ServiceSetupError].}
118118
p.connManager = switch.connManager
119119
p.peerInfo = switch.peerInfo
120120

121-
proc onIncomingPush(peerId: PeerId, info: IdentifyInfo) {.async.} =
121+
proc onIncomingPush(info: IdentifyInfo) {.async.} =
122122
if not p.started:
123123
return
124124

125125
p.peerStore.updatePeerInfo(info)
126126
if IdentifyPushCodec in info.protos:
127-
p.pushPeers.incl(peerId)
127+
p.pushPeers.incl(info.peerId)
128128
else:
129-
p.pushPeers.excl(peerId)
129+
p.pushPeers.excl(info.peerId)
130130

131131
p.identifyPush = IdentifyPush.new(onIncomingPush)
132132

tests/libp2p/protocols/test_identify.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ suite "Identify":
177177
.withSignedPeerRecord(true)
178178
.build()
179179

180-
proc updateStore1(peerId: PeerId, info: IdentifyInfo) {.async.} =
180+
proc updateStore1(info: IdentifyInfo) {.async.} =
181181
switch1.peerStore.updatePeerInfo(info)
182182

183-
proc updateStore2(peerId: PeerId, info: IdentifyInfo) {.async.} =
183+
proc updateStore2(info: IdentifyInfo) {.async.} =
184184
switch2.peerStore.updatePeerInfo(info)
185185

186186
identifyPush1 = IdentifyPush.new(updateStore1)

0 commit comments

Comments
 (0)