Skip to content

Commit

Permalink
Add a 10ms delay after events.
Browse files Browse the repository at this point in the history
  • Loading branch information
chmac committed Aug 10, 2024
1 parent 32b7d5e commit 8fde5ac
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export const MINIMUM_TRUSTROOTS_USERNAME_LENGTH = 3;
export const WAIT_FOR_KIND_ZERO_TIMEOUT_SECONDS = 5;

export const DEV_PUBKEY =
"80789235a71a388074abfa5c482e270456d2357425266270f82071cf2b1de74a" as const
"80789235a71a388074abfa5c482e270456d2357425266270f82071cf2b1de74a" as const;

export const HITCHMAPS_AUTHOR_PUBLIC_KEY =
"53055ee011e96a00a705b38253b9cbc6614ccbd37df4dad42ec69bbe608c4209" as const;

export const DELAY_AFTER_PROCESSING_EVENT_MS = 10;
4 changes: 4 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export const newQueue = newQueueImport;
// import * as logImport from "jsr:@std/[email protected]";
// export const log = logImport.getLogger("nostroots-server");
export * as logPackage from "jsr:@std/[email protected]";
export * as async from "jsr:@std/[email protected]";
4 changes: 4 additions & 0 deletions validation/repost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { validateEvent } from "./validate.ts";
import { newQueue } from "../deps.ts";
import { nostrTools } from "../deps.ts";
import { log } from "../log.ts";
import { async } from "../deps.ts";
import { DELAY_AFTER_PROCESSING_EVENT_MS } from "../common/constants.ts";

async function getRelayPool(isDev: true | undefined) {
const relays = isDev ? DEV_RELAYS : DEFAULT_RELAYS;
Expand Down Expand Up @@ -120,6 +122,8 @@ function processEventFactoryFactory(
}
const repostedEvent = await generateRepostedEvent(event, privateKey);
publishEvent(relayPool, repostedEvent);

await async.delay(DELAY_AFTER_PROCESSING_EVENT_MS);
};
};
}
Expand Down

0 comments on commit 8fde5ac

Please sign in to comment.