Skip to content

Commit 15819b3

Browse files
committed
update network capabilities array
1 parent dd84942 commit 15819b3

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

packages/portalnetwork/src/networks/history/history.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
ContentMessageType,
77
FoundContent,
88
MessageCodes,
9+
PingPongPayloadExtensions,
910
PortalWireMessageType,
1011
RequestCode,
1112
decodeHistoryNetworkContentKey,
@@ -38,7 +39,10 @@ export class HistoryNetwork extends BaseNetwork {
3839
public blockHashIndex: Map<string, string>
3940
constructor({ client, db, radius, maxStorage }: BaseNetworkConfig) {
4041
super({ client, networkId: NetworkId.HistoryNetwork, db, radius, maxStorage })
41-
this.capabilities = [0, 1, 2, 65535]
42+
this.capabilities = [
43+
PingPongPayloadExtensions.CLIENT_INFO_RADIUS_AND_CAPABILITIES,
44+
PingPongPayloadExtensions.HISTORY_RADIUS_PAYLOAD,
45+
]
4246
this.networkId = NetworkId.HistoryNetwork
4347
this.logger = debug(this.enr.nodeId.slice(0, 5)).extend('Portal').extend('HistoryNetwork')
4448
this.routingTable.setLogger(this.logger)

packages/portalnetwork/src/networks/network.ts

+15-8
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ import type * as PromClient from 'prom-client'
6262
import { GossipManager } from './gossip.js'
6363

6464
export abstract class BaseNetwork extends EventEmitter {
65-
public capabilities: number[] = [0, 1, 65535]
65+
public capabilities: number[] = [
66+
PingPongPayloadExtensions.CLIENT_INFO_RADIUS_AND_CAPABILITIES,
67+
PingPongPayloadExtensions.BASIC_RADIUS_PAYLOAD,
68+
]
6669
static MAX_CONCURRENT_UTP_STREAMS = 50
6770
public routingTable: PortalNetworkRoutingTable
6871
public nodeRadius: bigint
@@ -321,7 +324,9 @@ export abstract class BaseNetwork extends EventEmitter {
321324
switch (type) {
322325
case PingPongPayloadExtensions.CLIENT_INFO_RADIUS_AND_CAPABILITIES: {
323326
const { ClientInfo, Capabilities } = ClientInfoAndCapabilities.deserialize(payload)
324-
this.logger.extend('PONG')(`Client ${shortId(enr.nodeId)} is ${decodeClientInfo(ClientInfo).clientName} node with capabilities: ${Capabilities}`)
327+
this.logger.extend('PONG')(
328+
`Client ${shortId(enr.nodeId)} is ${decodeClientInfo(ClientInfo).clientName} node with capabilities: ${Capabilities}`,
329+
)
325330
break
326331
}
327332
case PingPongPayloadExtensions.BASIC_RADIUS_PAYLOAD: {
@@ -380,17 +385,19 @@ export abstract class BaseNetwork extends EventEmitter {
380385
pongPayload = this.pingPongPayload(type)
381386
break
382387
}
383-
case PingPongPayloadExtensions.HISTORY_RADIUS_PAYLOAD: {
388+
case PingPongPayloadExtensions.HISTORY_RADIUS_PAYLOAD: {
384389
if (this.networkId !== NetworkId.HistoryNetwork) {
385390
pongPayload = ErrorPayload.serialize({
386391
errorCode: 0,
387-
message: hexToBytes(fromAscii('HISTORY_RADIUS extension not supported on this network')),
392+
message: hexToBytes(
393+
fromAscii('HISTORY_RADIUS extension not supported on this network'),
394+
),
388395
})
389396
} else {
390-
const { dataRadius } = HistoryRadius.deserialize(payload)
391-
this.routingTable.updateRadius(src.nodeId, dataRadius)
392-
pongPayload = this.pingPongPayload(type)
393-
}
397+
const { dataRadius } = HistoryRadius.deserialize(payload)
398+
this.routingTable.updateRadius(src.nodeId, dataRadius)
399+
pongPayload = this.pingPongPayload(type)
400+
}
394401
break
395402
}
396403
default: {

0 commit comments

Comments
 (0)