Skip to content

Commit

Permalink
apply changes in hydra-node.ts too
Browse files Browse the repository at this point in the history
The dedicated server uses a different implementation because of dumb reasons lol
  • Loading branch information
Quantumplation committed Dec 14, 2024
1 parent 3e32fb7 commit d7be269
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/utils/hydra-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export class Hydra {
constructor(
url: string | URL,
filterAddress?: string,
onConnect?: () => void,
onDisconnect?: () => void,
public queue_length: number = 10,
) {
this.tx_count = 0;
Expand All @@ -70,19 +72,22 @@ export class Hydra {
this.url.protocol = this.url.protocol.replace("ws", "http");
const websocketUrl = new URL(url);
websocketUrl.protocol = websocketUrl.protocol.replace("http", "ws");
console.log(`onConnect: ${!!onConnect}, onDisconnect: ${!!onDisconnect}`);
this.connection = new WebSocket(
websocketUrl +
(websocketUrl.toString().endsWith("/") ? "" : "/") +
`?${filterAddress ? `address=${filterAddress}&` : ""}history=no`,
);
this.connection.onopen = () => {
console.log("Connected to Hydra");
console.log("Connected to Hydra, callback: ", !!onConnect);
onConnect?.();
};
this.connection.onerror = (error) => {
console.error("Error on Hydra websocket: ", error);
};
this.connection.onclose = () => {
console.error("Hydra websocket closed");
console.error("Hydra websocket closed, callback: ", !!onDisconnect);
onDisconnect?.();
};
this.connection.onmessage = this.receiveMessage.bind(this);
}
Expand Down

0 comments on commit d7be269

Please sign in to comment.