*DHT connect in queryRelay can be a promise

This commit is contained in:
Derrick Hammer 2022-07-19 14:46:10 -04:00
parent 1c18b041f3
commit da06f787dc
1 changed files with 10 additions and 1 deletions

View File

@ -63,7 +63,16 @@ export default class RpcQuery {
} }
private async queryRelay(relay: string): Promise<any> { private async queryRelay(relay: string): Promise<any> {
const socket = this._network.dht.connect(Buffer.from(relay, "hex")); let socket: any;
try {
socket = this._network.dht.connect(Buffer.from(relay, "hex"));
if (isPromise(socket)) {
socket = await socket;
}
} catch (e) {
return;
}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
socket.on("data", (res: Buffer) => { socket.on("data", (res: Buffer) => {
socket.end(); socket.end();