Skip to content

Commit

Permalink
more nits
Browse files Browse the repository at this point in the history
  • Loading branch information
acolytec3 committed Oct 13, 2023
1 parent 9f4a593 commit f268e02
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ const main = async () => {
portal.discv5.enableLogs()

// portal.enableLog(
// 'ultralight,-FINDNODES,*LightClient:DEBUG,*LightClient:INFO,*BeaconLightClientNetwork,*BOOTSTRAP,*OFFER,*ACCEPT,*FINDCONTENT,*FOUNDCONTENT,*uTP',
// )
// 'ultralight,-FINDNODES,*LightClient:DEBUG,*LightClient:INFO,*BeaconLightClientNetwork,*BOOTSTRAP,*OFFER,*ACCEPT,*FINDCONTENT,*FOUNDCONTENT,*uTP:FINISHED',
// )
portal.enableLog('*Portal*,uTP*')

const rpcAddr = args.rpcAddr ?? ip // Set RPC address (used by metrics server and rpc server)
Expand Down
27 changes: 14 additions & 13 deletions packages/portalnetwork/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
NodeId,
ENR,
createKeypairFromPeerId,
createPeerIdFromKeypair,
} from '@chainsafe/discv5'
import { ITalkReqMessage, ITalkRespMessage } from '@chainsafe/discv5/message'
import { EventEmitter } from 'events'
Expand Down Expand Up @@ -224,21 +225,21 @@ export class PortalNetwork extends (EventEmitter as { new (): PortalNetworkEvent
// if (this.discv5.sessionService.transport instanceof HybridTransportService) {
// ;(this.discv5.sessionService as any).send = this.send.bind(this)
// }
this.discv5.sessionService.on('established', async (nodeAddr, enr, _, _verified) => {
this.discv5.sessionService.on('established', async (nodeAddr, enr, _, verified) => {
this.discv5.findEnr(enr.nodeId) === undefined && this.discv5.addEnr(enr)

// if (!verified || !enr.getLocationMultiaddr('udp')) {
// // If a node provides an invalid ENR during the discv5 handshake, we cache the multiaddr
// // corresponding to the node's observed IP/Port so that we can send outbound messages to
// // those nodes later on if needed. This is currently used by uTP when responding to
// // FINDCONTENT requests from nodes with invalid ENRs.
// const peerId = await createPeerIdFromKeypair(enr.keypair)
// this.unverifiedSessionCache.set(
// enr.nodeId,
// multiaddr(nodeAddr.socketAddr.toString() + '/p2p/' + peerId.toString())
// )
// this.logger(this.unverifiedSessionCache.get(enr.nodeId))
// }
if (!verified || !enr.getLocationMultiaddr('udp')) {
// If a node provides an invalid ENR during the discv5 handshake, we cache the multiaddr
// corresponding to the node's observed IP/Port so that we can send outbound messages to
// those nodes later on if needed. This is currently used by uTP when responding to
// FINDCONTENT requests from nodes with invalid ENRs.
const peerId = await createPeerIdFromKeypair(enr.keypair)
this.unverifiedSessionCache.set(
enr.nodeId,
multiaddr(nodeAddr.socketAddr.toString() + '/p2p/' + peerId.toString()),
)
this.logger(this.unverifiedSessionCache.get(enr.nodeId))
}
})

if (opts.metrics) {
Expand Down
2 changes: 1 addition & 1 deletion packages/portalnetwork/src/subprotocols/beacon/beacon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ export class BeaconLightClientNetwork extends BaseProtocol {
this.metrics?.contentMessagesSent.inc()

this.logger(
`Received handleFindContent request for contentKey: ${toHexString(
`Received FindContent request for contentKey: ${toHexString(
decodedContentMessage.contentKey,
)}`,
)
Expand Down
2 changes: 1 addition & 1 deletion packages/portalnetwork/src/subprotocols/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ export abstract class BaseProtocol extends EventEmitter {
this.metrics?.contentMessagesSent.inc()

this.logger(
`Received handleFindContent request for contentKey: ${toHexString(
`Received FindContent request for contentKey: ${toHexString(
decodedContentMessage.contentKey,
)}`,
)
Expand Down
1 change: 0 additions & 1 deletion packages/portalnetwork/src/wire/utp/Socket/UtpSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ export class UtpSocket extends EventEmitter {
try {
await this.packetManager.congestionControl.canSend()
} catch (e) {
console.trace(e)
this.logger(`DATA packet not acked. Closing connection to ${this.remoteAddress}`)
await this.sendResetPacket()
this.close()
Expand Down

0 comments on commit f268e02

Please sign in to comment.