[bug] Prevent duplicated addresses when sharing secrets
This commit is contained in:
parent
1c92a40984
commit
420979e63e
@ -211,7 +211,7 @@ export default class Services {
|
|||||||
public async checkConnections(members: Member[]): Promise<void> {
|
public async checkConnections(members: Member[]): Promise<void> {
|
||||||
// Ensure the amount is available before proceeding
|
// Ensure the amount is available before proceeding
|
||||||
await this.getTokensFromFaucet();
|
await this.getTokensFromFaucet();
|
||||||
let unconnectedAddresses = [];
|
let unconnectedAddresses: Set<string> = new Set();
|
||||||
const myAddress = this.getDeviceAddress();
|
const myAddress = this.getDeviceAddress();
|
||||||
for (const member of members) {
|
for (const member of members) {
|
||||||
const sp_addresses = member.sp_addresses;
|
const sp_addresses = member.sp_addresses;
|
||||||
@ -221,12 +221,12 @@ export default class Services {
|
|||||||
if (address === myAddress) continue;
|
if (address === myAddress) continue;
|
||||||
const sharedSecret = await this.getSecretForAddress(address);
|
const sharedSecret = await this.getSecretForAddress(address);
|
||||||
if (!sharedSecret) {
|
if (!sharedSecret) {
|
||||||
unconnectedAddresses.push(address);
|
unconnectedAddresses.add(address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (unconnectedAddresses && unconnectedAddresses.length != 0) {
|
if (unconnectedAddresses && unconnectedAddresses.size != 0) {
|
||||||
const apiResult = await this.connectAddresses(unconnectedAddresses);
|
const apiResult = await this.connectAddresses([...unconnectedAddresses]);
|
||||||
await this.handleApiReturn(apiResult);
|
await this.handleApiReturn(apiResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user