Skip to content

Commit

Permalink
Revert "update getContactableAddr impl"
Browse files Browse the repository at this point in the history
This reverts commit 282b0ad.
  • Loading branch information
acolytec3 authored and ScottyPoi committed Aug 11, 2023
1 parent f760aae commit 13a4163
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:18-alpine as BUILD_IMAGE
FROM node:16-alpine as BUILD_IMAGE
WORKDIR /app
RUN apk update && apk add --no-cache bash && rm -rf /var/cache/apk/*
RUN apk add --virtual .build-deps alpine-sdk jq

RUN ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2


#RUN jq -r '.workspaces |= .[0:2]' package.json > package.json
RUN jq -r '.workspaces |= .[0:2]' package.json > package.json
COPY package*.json ./
RUN npm ci --ignore-scripts --omit-dev

Expand Down
11 changes: 9 additions & 2 deletions packages/portalnetwork/src/transports/capacitorUdp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
TransportEventEmitter,
} from '@chainsafe/discv5/transport'
import { BaseENR } from '@chainsafe/discv5'
import { SocketAddress, getSocketAddressOnENR } from '@chainsafe/discv5/lib/util/ip.js'
import { SocketAddress } from '@chainsafe/discv5/lib/util/ip.js'

/**
* This class is responsible for encoding outgoing Packets and decoding incoming Packets over UDP
Expand Down Expand Up @@ -84,6 +84,13 @@ export class CapacitorUDPTransportService
}

getContactableAddr(enr: BaseENR): SocketAddress | undefined {
return getSocketAddressOnENR(enr, this.ipMode)
const nodeAddr = this.bindAddrs[0].tuples()
return {
port: this.bindAddrs[0].nodeAddress().port,
ip: {
type: 4,
octets: nodeAddr[0][1] ?? new Uint8Array([0, 0, 0, 0]),
},
}
}
}
11 changes: 9 additions & 2 deletions packages/portalnetwork/src/transports/hybridTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { WebSocketTransportService } from '../index.js'
import { WakuPortal } from './waku.js'
import WebRTC from './webRTC.js'
import { BaseENR, SignableENR, ISocketAddr } from '@chainsafe/discv5'
import { SocketAddress, getSocketAddressOnENR } from '@chainsafe/discv5/lib/util/ip.js'
import { SocketAddress } from '@chainsafe/discv5/lib/util/ip.js'

interface IHybridTransportEvents extends ITransportEvents {
multiAddr: (src: Multiaddr) => void
Expand Down Expand Up @@ -149,6 +149,13 @@ export class HybridTransportService
}

getContactableAddr(enr: BaseENR): SocketAddress | undefined {
return getSocketAddressOnENR(enr, this.ipMode)
const nodeAddr = this.bindAddrs[0].tuples()
return {
port: this.bindAddrs[0].nodeAddress().port,
ip: {
type: 4,
octets: nodeAddr[0][1] ?? new Uint8Array([0, 0, 0, 0]),
},
}
}
}
11 changes: 9 additions & 2 deletions packages/portalnetwork/src/transports/websockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import WebSocketAsPromised from 'websocket-as-promised'
import WebSocket from 'isomorphic-ws'
import StrictEventEmitter from 'strict-event-emitter-types/types/src'
import { SocketAddress, getSocketAddressOnENR } from '@chainsafe/discv5/lib/util/ip.js'
import { SocketAddress } from '@chainsafe/discv5/lib/util/ip.js'
import { BaseENR } from '@chainsafe/discv5'
const log = debug('discv5:transport')

Expand Down Expand Up @@ -114,6 +114,13 @@ export class WebSocketTransportService
}

getContactableAddr(enr: BaseENR): SocketAddress | undefined {
return getSocketAddressOnENR(enr, this.ipMode)
const nodeAddr = this.bindAddrs[0].tuples()
return {
port: this.bindAddrs[0].nodeAddress().port,
ip: {
type: 4,
octets: nodeAddr[0][1] ?? new Uint8Array([0, 0, 0, 0]),
},
}
}
}

0 comments on commit 13a4163

Please sign in to comment.