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

Revert "Disable the ability of fe1 to send messages to peers" #1888

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions fe1-web/src/features/lao/network/LaoGreetWatcher.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Store } from 'redux';

import { getNetworkManager } from 'core/network';
import { getMessagesState } from 'core/network/ingestion';
import { ExtendedMessage } from 'core/network/ingestion/ExtendedMessage';
import { Hash, PublicKey, WitnessSignature, WitnessSignatureState } from 'core/objects';
Expand Down Expand Up @@ -37,16 +38,21 @@ export const storeBackendAndConnectToPeers = async (
),
);

// connect to all received peer addresses
// after connecting to each peer, we will send a catchup which contains the lao#create message
// as soon as we have parsed this message, we will connect to the LAO on the new connection as well
// which will trigger another lao#greet message
// IMPORTANT: The network manager deduplicates connections to the same address (string)
// and the received peer addresses are supposed to be the canonical ones.
// Hence we just have to make sure that the first connection is also to the canonical
// address, otherwise a client will connect to the same server twice (e.g. using its IP and then
// then using the canonical domain address)
const networkManager = getNetworkManager();

try {
// connect to all received peer addresses
// after connecting to each peer, we will send a catchup which contains the lao#create message
// as soon as we have parsed this message, we will connect to the LAO on the new connection as well
// which will trigger another lao#greet message
// IMPORTANT: The network manager deduplicates connections to the same address (string)
// and the received peer addresses are supposed to be the canonical ones.
// Hence we just have to make sure that the first connection is also to the canonical
// address, otherwise a client will connect to the same server twice (e.g. using its IP and then
// then using the canonical domain address)
await Promise.all(
greetLaoMsg.peers.map((peerAddress) => networkManager.connect(peerAddress.address)),
);

// mark the lao#greet message as handled
dispatch(
Expand Down
Loading