Skip to content

Commit

Permalink
cache lookup enrs
Browse files Browse the repository at this point in the history
  • Loading branch information
acolytec3 committed Dec 5, 2024
1 parent f8600d0 commit 5c75eb5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/portalnetwork/src/networks/contentLookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ export class ContentLookup {
}

this.pending.add(peer.enr.encodeTxt())
this.network.portal.enrCache.set(peer.enr.nodeId, peer.enr)
this.logger(`Requesting content from ${shortId(peer.enr.nodeId)}`)
try {
const res = await this.network.sendFindContent!(peer.enr.encodeTxt(), this.contentKey)
const res = await this.network.sendFindContent!(peer.enr.nodeId, this.contentKey)
this.pending.delete(peer.enr.encodeTxt())
if (this.finished) {
this.logger(`Response from ${shortId(peer.enr.nodeId)} arrived after lookup finished`)
Expand Down
5 changes: 2 additions & 3 deletions packages/portalnetwork/src/networks/history/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import {
RequestCode,
decodeHistoryNetworkContentKey,
decodeReceipts,
getENR,
reassembleBlock,
saveReceipts,
shortId,
shortId
} from '../../index.js'
import { BaseNetwork } from '../network.js'
import { NetworkId } from '../types.js'
Expand Down Expand Up @@ -196,7 +195,7 @@ export class HistoryNetwork extends BaseNetwork {
* @returns the value of the FOUNDCONTENT response or undefined
*/
public sendFindContent = async (dstId: string, key: Uint8Array) => {
const enr = getENR(this.routingTable, dstId)
const enr = this.portal.enrCache.get(dstId)
if (enr === undefined) {
this.logger(`No ENR found for ${shortId(dstId)}. FINDCONTENT aborted.`)
return undefined
Expand Down

0 comments on commit 5c75eb5

Please sign in to comment.