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

refactor(dht): Do not store ConnectionType #2049

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

teogeb
Copy link
Contributor

@teogeb teogeb commented Nov 10, 2023

We don't need to store a connectionType value for each ManagedConnection instance as the information can be queried by calling the expectedConnectionType helper function. The helper was introduced in #2043.

Removed obsolete ConnectionType#SIMULATOR_* enum values.

Future improvements

ConnectionType could be string literals instead of enum values as we prefer those nowadays.

@github-actions github-actions bot added the dht Related to DHT package label Nov 10, 2023
@teogeb teogeb requested a review from juslesan November 10, 2023 15:19
@teogeb teogeb changed the title refactor(dht): Remove ConnectionType refactor(dht): Do not store ConnectionType Nov 16, 2023
Copy link
Contributor

@harbu harbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds to me (on the surface level) like we should keep the logging statements and tests assertions related to connectionType. But instead of storing connectionType we can infer it statically with a helper function?

@@ -362,7 +362,7 @@ export class ConnectionManager extends EventEmitter<TransportEvents> implements
private onConnected(connection: ManagedConnection) {
const peerDescriptor = connection.getPeerDescriptor()!
this.emit('connected', peerDescriptor)
logger.trace(getNodeIdFromPeerDescriptor(peerDescriptor) + ' onConnected() ' + connection.connectionType)
logger.trace(getNodeIdFromPeerDescriptor(peerDescriptor) + ' onConnected()')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep the connectionType in the logging statements when it is relevant.

Comment on lines 73 to 74
expect((node1.getTransport() as ConnectionManager).getConnection(node2.getLocalPeerDescriptor())!.connectionType)
.toEqual(ConnectionType.WEBRTC)
expect((node2.getTransport() as ConnectionManager).getConnection(node1.getLocalPeerDescriptor())!.connectionType)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These assertions related to connectionType are important to validate?

Base automatically changed from streamr-1.0 to main December 27, 2023 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dht Related to DHT package requires-discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants