Skip to content

Commit

Permalink
Revert "types from latest monorepo"
Browse files Browse the repository at this point in the history
This reverts commit f985d5c.
  • Loading branch information
teogeb committed Oct 24, 2024
1 parent 765a69a commit d4443de
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
7 changes: 2 additions & 5 deletions src/crawler/Crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,10 @@ const createNodeInfoLogOutput = (nodeInfo: NormalizedNodeInfo) => {
neighbors: nodeInfo.controlLayer!.neighbors.map(toNodeId),
connections: nodeInfo.controlLayer!.connections.map(toNodeId)
},
streamPartitions: nodeInfo.streamPartitions.map((sp) => ({
streamPartitions: nodeInfo.streamPartitions.map((sp: any) => ({
id: sp.id,
controlLayerNeighbors: sp.controlLayerNeighbors.map(toNodeId),
contentDeliveryLayerNeighbors: sp.contentDeliveryLayerNeighbors.map((n) => ({
nodeId: toNodeId(n.peerDescriptor),
rtt: n.rtt
}))
contentDeliveryLayerNeighbors: sp.contentDeliveryLayerNeighbors.map((n: any) => toNodeId(n.peerDescriptor)) // TODO better type
})),
version: nodeInfo.version
}
Expand Down
15 changes: 8 additions & 7 deletions src/crawler/NetworkNodeFacade.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PeerDescriptor } from '@streamr/dht'
import { NetworkNode, NodeInfo, StreamMessage, streamPartIdToDataKey, StreamPartitionInfo } from '@streamr/trackerless-network'
import { ChangeFieldType, StreamPartID } from '@streamr/utils'
import { NetworkNode, NodeInfo, StreamMessage, streamPartIdToDataKey } from '@streamr/trackerless-network'
import { StreamPartID } from '@streamr/utils'
import EventEmitter3 from 'eventemitter3'
import semver from 'semver'
import { Config } from '../Config'
Expand All @@ -10,16 +10,17 @@ export interface Events {
unsubscribe: () => void
}

export type NormalizedNodeInfo = ChangeFieldType<
NodeInfo,
'streamPartitions',
Omit<StreamPartitionInfo, 'deprecatedContentDeliveryLayerNeighbors'>[]>
type ArrayElement<ArrayType extends readonly unknown[]> =
ArrayType extends readonly (infer ElementType)[] ? ElementType : never

export type NormalizedNodeInfo = Omit<NodeInfo, 'streamPartitions'>
& { streamPartitions: Omit<ArrayElement<NodeInfo['streamPartitions']>, 'deprecatedContentDeliveryLayerNeighbors'>[] }

const toNormalizeNodeInfo = (info: NodeInfo): NormalizedNodeInfo => {
const isLegacyFormat = semver.satisfies(semver.coerce(info.version)!, '< 102.0.0')
return {
...info,
streamPartitions: info.streamPartitions.map((sp: StreamPartitionInfo) => ({
streamPartitions: info.streamPartitions.map((sp) => ({
...sp,
contentDeliveryLayerNeighbors: !isLegacyFormat
? sp.contentDeliveryLayerNeighbors
Expand Down
6 changes: 4 additions & 2 deletions test/end-to-end.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'reflect-metadata'

import { DhtAddress, NodeType, randomDhtAddress, toDhtAddress, toDhtAddressRaw } from '@streamr/dht'
import StreamrClient, { NetworkNodeType, PeerDescriptor, StreamID, StreamPermission, StreamrClientConfig } from '@streamr/sdk'
import StreamrClient, { CONFIG_TEST, NetworkNodeType, PeerDescriptor, StreamID, StreamPermission, StreamrClientConfig } from '@streamr/sdk'
import { NetworkNode, createNetworkNode } from '@streamr/trackerless-network'
import { StreamPartID, collect, setAbortableInterval, toStreamPartID, waitForCondition } from '@streamr/utils'
import { sample, uniq, without } from 'lodash'
Expand Down Expand Up @@ -50,9 +50,11 @@ const startEntryPoint = async (): Promise<NetworkNode> => {

const createClientConfig = (entryPointPeerDescriptor: PeerDescriptor): StreamrClientConfig => {
return {
environment:'dev2',
...CONFIG_TEST,
network: {
...CONFIG_TEST.network,
controlLayer: {
...CONFIG_TEST.network!.controlLayer,
entryPoints: [{
nodeId: toDhtAddress(entryPointPeerDescriptor.nodeId),
type: NetworkNodeType.NODEJS,
Expand Down

0 comments on commit d4443de

Please sign in to comment.