Skip to content

Commit

Permalink
RPC: implement recursiveFindNodes for state,beacon
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottyPoi committed Nov 5, 2024
1 parent 77cc5c1 commit c852686
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/cli/src/rpc/modules/portal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ export class portal {
this.historyRecursiveFindNodes = middleware(this.historyRecursiveFindNodes.bind(this), 1, [
[validators.dstId],
])
this.stateRecursiveFindNodes = middleware(this.stateRecursiveFindNodes.bind(this), 1, [
[validators.dstId],
])
this.beaconRecursiveFindNodes = middleware(this.beaconRecursiveFindNodes.bind(this), 1, [
[validators.dstId],
])

// portal_*SendNodes
this.historySendNodes = middleware(this.historySendNodes.bind(this), 2, [
Expand Down Expand Up @@ -768,6 +774,24 @@ export class portal {
this.logger(`historyRecursiveFindNodes request returned ${res}`)
return res ?? ''
}
async stateRecursiveFindNodes(params: [string]) {
const [dstId] = params
this.logger(`stateRecursiveFindNodes request received for ${dstId}`)
const target = dstId.startsWith('0x') ? dstId.slice(2) : dstId
const lookup = new NodeLookup(this._state, target)
const res = await lookup.startLookup()
this.logger(`stateRecursiveFindNodes request returned ${res}`)
return res ?? ''
}
async beaconRecursiveFindNodes(params: [string]) {
const [dstId] = params
this.logger(`beaconRecursiveFindNodes request received for ${dstId}`)
const target = dstId.startsWith('0x') ? dstId.slice(2) : dstId
const lookup = new NodeLookup(this._beacon, target)
const res = await lookup.startLookup()
this.logger(`beaconRecursiveFindNodes request returned ${res}`)
return res ?? ''
}

// portal_*SendNodes
async historySendNodes(params: [string, string[], string]) {
Expand Down

0 comments on commit c852686

Please sign in to comment.