Skip to content

Comments

Add libp2p#1

Open
Yuliia05 wants to merge 27 commits intomainfrom
add-libp2p
Open

Add libp2p#1
Yuliia05 wants to merge 27 commits intomainfrom
add-libp2p

Conversation

@Yuliia05
Copy link
Collaborator

No description provided.

@MAKMED1337 MAKMED1337 self-requested a review December 18, 2025 01:03
Copy link
Collaborator

@MAKMED1337 MAKMED1337 left a comment

Choose a reason for hiding this comment

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

Should we remove TeachBound prefixes from folders ?
Investigate is dedupe really needed.
Initial sync works when delay is added, react wants all the functions to be pure, so probably global singleton is a problem

"scripts": {
"start": "node --env-file=.env src/host.js",
"generate-env": "node src/generate_seed.js > .env",
"test": "echo \"Error: no test specified\" && exit 1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this line

console.log('[TeachBound-host] Peer disconnected:', evt.detail.toString());
});

// Subscribe to common topics to relay messages
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need more than 1 topic ?

CANVAS_CLEAR: 'canvas_clear',
SNAPSHOT_REQUEST: 'snapshot_request',
SNAPSHOT_RESPONSE: 'snapshot_response',
DEBUG_HELLO: 'debug_hello',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can it be removed?

Comment on lines +22 to +29
export function generateMessageId() {
// crypto.randomUUID is widely supported in modern browsers and Node.
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
return crypto.randomUUID();
}
// Fallback: best-effort uniqueness for local dev.
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can it be united with generateElementId from ids.js?

maxConnections: 50,
minConnections: 0
},
// Allow connections to local/insecure addresses for development
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess it should be hidden by some env flags

```

4. (Optional) Enable P2P collaboration in the client:
- Create `TeachBound-client/.env` (this file is intentionally ignored by git)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This file is not ignored?

Comment on lines 4 to 5
process.env.REACT_APP_P2P_SIGNALING_ADDR = '';
process.env.REACT_APP_P2P_HOST = '';
Copy link
Collaborator

Choose a reason for hiding this comment

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

console.warn
    No REACT_APP_P2P_SIGNALING_ADDR (or legacy REACT_APP_P2P_HOST) set

We are returning immediately in the main

Comment on lines 170 to 171
const signalingAddr = process.env.REACT_APP_P2P_SIGNALING_ADDR;
const legacyHostAddr = process.env.REACT_APP_P2P_HOST;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should stuck to only one option, and drop the REACT_APP prefix

Comment on lines +274 to +275
* Schedule stopping the node after a delay.
* Useful for React StrictMode double-mount handling.
Copy link
Collaborator

Choose a reason for hiding this comment

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

In Strict Mode, React will call your component function twice in order to [help you find accidental impurities.](https://react.dev/reference/react/useState#my-initializer-or-updater-function-runs-twice) This is development-only behavior and does not affect production. Each ref object will be created twice, but one of the versions will be discarded. If your component function is pure (as it should be), this should not affect the behavior.

https://react.dev/learn/keeping-components-pure

We are doing something wrong


export const P2P_PROTOCOL_VERSION = 1;

export const P2P_EVENT_TYPES = Object.freeze({
Copy link
Collaborator

Choose a reason for hiding this comment

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

No undo action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants