refactor: delay batches until req's finish
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Kieran 2024-01-19 10:26:37 +00:00
parent 2b1cf34424
commit 0b307ae691
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941

View File

@ -44,7 +44,9 @@ async function reply<T>(id: string, obj?: T, transferables?: Transferable[]) {
// Event inserter queue
let eventWriteQueue: Array<NostrEvent> = [];
async function insertBatch() {
if (eventWriteQueue.length > 0) {
// Only insert event batches when the command queue is empty
// This is to make req's execute first and not block them
if (eventWriteQueue.length > 0 && cmdQueue.length === 0) {
relay.eventBatch(eventWriteQueue);
eventWriteQueue = [];
}