fix: use command queue for batch event write
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
72b98a4ab5
commit
da6fa415dd
@ -31,9 +31,14 @@ let eventWriteQueue: Array<NostrEvent> = [];
|
|||||||
async function insertBatch() {
|
async function insertBatch() {
|
||||||
// Only insert event batches when the command queue is empty
|
// Only insert event batches when the command queue is empty
|
||||||
// This is to make req's execute first and not block them
|
// This is to make req's execute first and not block them
|
||||||
if (relay && eventWriteQueue.length > 0 && cmdQueue.length === 0) {
|
if (eventWriteQueue.length > 0 && cmdQueue.length === 0) {
|
||||||
relay.eventBatch(eventWriteQueue);
|
await barrierQueue(cmdQueue, async () => {
|
||||||
|
if (relay) {
|
||||||
|
const toWrite = [...eventWriteQueue];
|
||||||
eventWriteQueue = [];
|
eventWriteQueue = [];
|
||||||
|
relay.eventBatch(toWrite);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
setTimeout(() => insertBatch(), 100);
|
setTimeout(() => insertBatch(), 100);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user