run disconnect-related writes in parallel
This commit is contained in:
parent
18844d2c55
commit
cd9c7983c8
1 changed files with 55 additions and 45 deletions
|
|
@ -372,7 +372,10 @@ const cleanup = async pub => {
|
|||
|
||||
const outGoingID = await Utils.recipientToOutgoingID(pub)
|
||||
|
||||
await new Promise((res, rej) => {
|
||||
const promises = []
|
||||
|
||||
promises.push(
|
||||
new Promise((res, rej) => {
|
||||
user
|
||||
.get(Key.USER_TO_INCOMING)
|
||||
.get(pub)
|
||||
|
|
@ -384,8 +387,10 @@ const cleanup = async pub => {
|
|||
}
|
||||
})
|
||||
})
|
||||
)
|
||||
|
||||
await new Promise((res, rej) => {
|
||||
promises.push(
|
||||
new Promise((res, rej) => {
|
||||
user
|
||||
.get(Key.RECIPIENT_TO_OUTGOING)
|
||||
.get(pub)
|
||||
|
|
@ -397,8 +402,10 @@ const cleanup = async pub => {
|
|||
}
|
||||
})
|
||||
})
|
||||
)
|
||||
|
||||
await new Promise((res, rej) => {
|
||||
promises.push(
|
||||
new Promise((res, rej) => {
|
||||
user
|
||||
.get(Key.USER_TO_LAST_REQUEST_SENT)
|
||||
.get(pub)
|
||||
|
|
@ -410,9 +417,11 @@ const cleanup = async pub => {
|
|||
}
|
||||
})
|
||||
})
|
||||
)
|
||||
|
||||
if (outGoingID) {
|
||||
await new Promise((res, rej) => {
|
||||
promises.push(
|
||||
new Promise((res, rej) => {
|
||||
user
|
||||
.get(Key.OUTGOINGS)
|
||||
.get(outGoingID)
|
||||
|
|
@ -424,7 +433,10 @@ const cleanup = async pub => {
|
|||
}
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
await Promise.all(promises)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1227,9 +1239,7 @@ const disconnect = async pub => {
|
|||
throw new Error('No handshake exists for this pub')
|
||||
}
|
||||
|
||||
await cleanup(pub)
|
||||
|
||||
await generateHandshakeAddress()
|
||||
await Promise.all([cleanup(pub), generateHandshakeAddress()])
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue