feat: rebroadcast

This commit is contained in:
2023-05-04 14:16:58 +01:00
parent 551169c2c7
commit 6fe9a27041
8 changed files with 237 additions and 12 deletions

View File

@ -267,10 +267,18 @@ export class NostrSystem {
* Write an event to a relay then disconnect
*/
async WriteOnceToRelay(address: string, ev: RawEvent) {
const c = new Connection(address, { write: true, read: false }, this.HandleAuth, true);
await c.Connect();
await c.SendAsync(ev);
c.Close();
return new Promise<void>((resolve, reject) => {
const c = new Connection(address, { write: true, read: false }, this.HandleAuth, true);
const t = setTimeout(reject, 5_000);
c.OnConnected = async () => {
clearTimeout(t);
await c.SendAsync(ev);
c.Close();
resolve();
};
c.Connect();
});
}
#changed() {