Skip to content

Commit

Permalink
Revert "Disable the ability of fe1 to send messages to peers"
Browse files Browse the repository at this point in the history
  • Loading branch information
4xiom5 authored May 26, 2024
1 parent 956db47 commit cabf04e
Showing 1 changed file with 15 additions and 9 deletions.
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

0 comments on commit cabf04e

Please sign in to comment.