Compare commits
3 Commits
1c92a40984
...
19da967605
Author | SHA1 | Date | |
---|---|---|---|
![]() |
19da967605 | ||
![]() |
d4223ce604 | ||
![]() |
420979e63e |
@ -211,7 +211,7 @@ export default class Services {
|
||||
public async checkConnections(members: Member[]): Promise<void> {
|
||||
// Ensure the amount is available before proceeding
|
||||
await this.getTokensFromFaucet();
|
||||
let unconnectedAddresses = [];
|
||||
let unconnectedAddresses: Set<string> = new Set();
|
||||
const myAddress = this.getDeviceAddress();
|
||||
for (const member of members) {
|
||||
const sp_addresses = member.sp_addresses;
|
||||
@ -221,12 +221,12 @@ export default class Services {
|
||||
if (address === myAddress) continue;
|
||||
const sharedSecret = await this.getSecretForAddress(address);
|
||||
if (!sharedSecret) {
|
||||
unconnectedAddresses.push(address);
|
||||
unconnectedAddresses.add(address);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (unconnectedAddresses && unconnectedAddresses.length != 0) {
|
||||
const apiResult = await this.connectAddresses(unconnectedAddresses);
|
||||
if (unconnectedAddresses && unconnectedAddresses.size != 0) {
|
||||
const apiResult = await this.connectAddresses([...unconnectedAddresses]);
|
||||
await this.handleApiReturn(apiResult);
|
||||
}
|
||||
}
|
||||
@ -504,15 +504,15 @@ export default class Services {
|
||||
await db.clearStore('diffs');
|
||||
}
|
||||
|
||||
async sendNewTxMessage(message: string) {
|
||||
sendNewTxMessage(message: string) {
|
||||
sendMessage('NewTx', message);
|
||||
}
|
||||
|
||||
async sendCommitMessage(message: string) {
|
||||
sendCommitMessage(message: string) {
|
||||
sendMessage('Commit', message);
|
||||
}
|
||||
|
||||
async sendCipherMessages(ciphers: string[]) {
|
||||
sendCipherMessages(ciphers: string[]) {
|
||||
for (let i = 0; i < ciphers.length; i++) {
|
||||
const cipher = ciphers[i];
|
||||
sendMessage('Cipher', cipher);
|
||||
@ -525,9 +525,10 @@ export default class Services {
|
||||
|
||||
async parseCipher(message: string) {
|
||||
const membersList = this.getAllMembers();
|
||||
const processes = await this.getProcesses();
|
||||
try {
|
||||
// console.log('parsing new cipher');
|
||||
const apiReturn = this.sdkClient.parse_cipher(message, membersList);
|
||||
const apiReturn = this.sdkClient.parse_cipher(message, membersList, processes);
|
||||
await this.handleApiReturn(apiReturn);
|
||||
|
||||
// Device 1 wait Device 2
|
||||
@ -602,7 +603,7 @@ export default class Services {
|
||||
}
|
||||
|
||||
if (apiReturn.new_tx_to_send && apiReturn.new_tx_to_send.transaction.length != 0) {
|
||||
await this.sendNewTxMessage(JSON.stringify(apiReturn.new_tx_to_send));
|
||||
this.sendNewTxMessage(JSON.stringify(apiReturn.new_tx_to_send));
|
||||
await new Promise(r => setTimeout(r, 500));
|
||||
}
|
||||
|
||||
@ -676,11 +677,11 @@ export default class Services {
|
||||
|
||||
if (apiReturn.commit_to_send) {
|
||||
const commit = apiReturn.commit_to_send;
|
||||
await this.sendCommitMessage(JSON.stringify(commit));
|
||||
this.sendCommitMessage(JSON.stringify(commit));
|
||||
}
|
||||
|
||||
if (apiReturn.ciphers_to_send && apiReturn.ciphers_to_send.length != 0) {
|
||||
await this.sendCipherMessages(apiReturn.ciphers_to_send);
|
||||
this.sendCipherMessages(apiReturn.ciphers_to_send);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1544,7 +1545,7 @@ export default class Services {
|
||||
if (dontRetry.includes(errorMsg)) { return; }
|
||||
// Wait and retry
|
||||
setTimeout(async () => {
|
||||
await this.sendCommitMessage(JSON.stringify(content));
|
||||
this.sendCommitMessage(JSON.stringify(content));
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user