Skip to content

Commit

Permalink
Stop after eose in dev.
Browse files Browse the repository at this point in the history
  • Loading branch information
chmac committed Aug 9, 2024
1 parent ae2c051 commit 51cb1d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ await new cliffy.Command()
const { isDev } = options;
const privateKey = getOrCreatePrivateKey(options.privateKeyNsec);

console.log(`#PnFUPS Startup isDev ${isDev}`);

repost(privateKey, isDev);
})
.parse(Deno.args);
5 changes: 5 additions & 0 deletions validation/repost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,19 @@ function createFilter(isDev: true | undefined): nostrTools.Filter {
export async function repost(privateKey: Uint8Array, isDev: true | undefined) {
const filter = createFilter(isDev);

const oneose = isDev ? () => relay.close() : () => {};

const sub = relay.subscribe([filter], {
onevent: (event) => {
console.log("#9wKiBL Got event", event);

if (!validateEvent(event)) {
console.info(`Discarding event…`);
return;
}
const repostedEvent = generateRepostedEvent(event, privateKey);
publishEvent(repostedEvent);
},
oneose,
});
}

0 comments on commit 51cb1d9

Please sign in to comment.