*DHT connect in queryRelay can be a promise
This commit is contained in:
parent
1c18b041f3
commit
da06f787dc
|
@ -63,7 +63,16 @@ export default class RpcQuery {
|
|||
}
|
||||
|
||||
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) => {
|
||||
socket.on("data", (res: Buffer) => {
|
||||
socket.end();
|
||||
|
|
Loading…
Reference in New Issue