Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update startLightClient endpoint #660

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions packages/cli/src/rpc/modules/portal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ENR } from '@chainsafe/enr'
import { BitArray } from '@chainsafe/ssz'
import { hexToBytes, short } from '@ethereumjs/util'
import {
BeaconLightClientNetworkContentType,
ContentLookup,
ContentMessageType,
FoundContent,
Expand All @@ -12,6 +13,7 @@ import {
PingPongCustomDataType,
PortalWireMessageType,
fromHexString,
getBeaconContentKey,
shortId,
toHexString,
} from 'portalnetwork'
Expand Down Expand Up @@ -1192,8 +1194,19 @@ export class portal {
const [bootstrapHash] = params
this.logger(`portal_beaconStartLightClient request received for ${bootstrapHash}`)
try {
await this._beacon.initializeLightClient(bootstrapHash)
return true
const lookup = new ContentLookup(
this._beacon,
getBeaconContentKey(
BeaconLightClientNetworkContentType.LightClientBootstrap,
fromHexString(bootstrapHash),
),
)
const res = await lookup.startLookup()
if (res !== undefined && 'content' in res) {
await this._beacon.initializeLightClient(bootstrapHash)
return true
}
return false
} catch (err: any) {
return err.message
}
Expand Down
Loading