Revert "fix stale relays bug"
This reverts commit 32c2e663a9ec94aa1b33e2bd8839603de8baceeb.
This commit is contained in:
parent
32c2e663a9
commit
eddba62575
@ -116,15 +116,6 @@ export default function useEventPublisher() {
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Write to every online relay using Blastr.
|
||||
* https://github.com/MutinyWallet/blastr
|
||||
*/
|
||||
broadcastWithBlastr: (ev: NEvent | undefined) => {
|
||||
if (ev) {
|
||||
System.WriteOnceToRelay("wss://nostr.mutinywallet.com", ev);
|
||||
}
|
||||
},
|
||||
muted: async (keys: HexKey[], priv: HexKey[]) => {
|
||||
if (pubKey) {
|
||||
const ev = NEvent.ForPubKey(pubKey);
|
||||
@ -260,6 +251,18 @@ export default function useEventPublisher() {
|
||||
return await signEvent(ev);
|
||||
}
|
||||
},
|
||||
saveRelays: async () => {
|
||||
if (pubKey) {
|
||||
const ev = NEvent.ForPubKey(pubKey);
|
||||
ev.Kind = EventKind.ContactList;
|
||||
ev.Content = JSON.stringify(relays);
|
||||
for (const pk of follows) {
|
||||
ev.Tags.push(new Tag(["p", pk], ev.Tags.length));
|
||||
}
|
||||
|
||||
return await signEvent(ev);
|
||||
}
|
||||
},
|
||||
saveRelaysSettings: async () => {
|
||||
if (pubKey) {
|
||||
const ev = NEvent.ForPubKey(pubKey);
|
||||
|
@ -18,33 +18,17 @@ const RelaySettingsPage = () => {
|
||||
const [newRelay, setNewRelay] = useState<string>();
|
||||
|
||||
async function saveRelays() {
|
||||
const updatedRelaysEvent = await publisher.saveRelaysSettings();
|
||||
let wasBlastrBrodcastSuccessful: boolean;
|
||||
|
||||
const ev = await publisher.saveRelays();
|
||||
publisher.broadcast(ev);
|
||||
publisher.broadcastForBootstrap(ev);
|
||||
try {
|
||||
publisher.broadcast(updatedRelaysEvent);
|
||||
publisher.broadcastForBootstrap(updatedRelaysEvent);
|
||||
const onlineRelays = await fetch("https://api.nostr.watch/v1/online").then(r => r.json());
|
||||
const settingsEv = await publisher.saveRelaysSettings();
|
||||
const rs = Object.keys(relays).concat(randomSample(onlineRelays, 20));
|
||||
publisher.broadcastAll(settingsEv, rs);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
try {
|
||||
publisher.broadcastWithBlastr(updatedRelaysEvent);
|
||||
wasBlastrBrodcastSuccessful = true;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
wasBlastrBrodcastSuccessful = false;
|
||||
}
|
||||
|
||||
if (!wasBlastrBrodcastSuccessful) {
|
||||
try {
|
||||
const onlineRelays = await fetch("https://api.nostr.watch/v1/online").then(r => r.json());
|
||||
const rs = Object.keys(relays).concat(randomSample(onlineRelays, 20));
|
||||
publisher.broadcastAll(updatedRelaysEvent, rs);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addRelay() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user