Skip to content

Commit

Permalink
update getContactableAddr impl
Browse files Browse the repository at this point in the history
  • Loading branch information
acolytec3 committed Aug 11, 2023
1 parent 675e61b commit 0331a05
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:16-alpine as BUILD_IMAGE
FROM node:18-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: 2 additions & 9 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 } from '@chainsafe/discv5/lib/util/ip.js'
import { SocketAddress, getSocketAddressOnENR } 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,13 +84,6 @@ export class CapacitorUDPTransportService
}

getContactableAddr(enr: BaseENR): SocketAddress | undefined {
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]),
},
}
return getSocketAddressOnENR(enr, this.ipMode)
}
}
11 changes: 2 additions & 9 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 } from '@chainsafe/discv5/lib/util/ip.js'
import { SocketAddress, getSocketAddressOnENR } from '@chainsafe/discv5/lib/util/ip.js'

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

getContactableAddr(enr: BaseENR): SocketAddress | undefined {
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]),
},
}
return getSocketAddressOnENR(enr, this.ipMode)
}
}
11 changes: 2 additions & 9 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 } from '@chainsafe/discv5/lib/util/ip.js'
import { SocketAddress, getSocketAddressOnENR } from '@chainsafe/discv5/lib/util/ip.js'
import { BaseENR } from '@chainsafe/discv5'
const log = debug('discv5:transport')

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

getContactableAddr(enr: BaseENR): SocketAddress | undefined {
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]),
},
}
return getSocketAddressOnENR(enr, this.ipMode)
}
}

0 comments on commit 0331a05

Please sign in to comment.