Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(ip: string, port: number, networkId: string) {
this.socket = new Socket();
this.ip = ip;
this.port = port;
this.arrivedExtensionMessage = [];
this.tcpBuffer = Buffer.alloc(0);
this.genesisHash = new H256("0000000000000000000000000000000000000000000000000000000000000000");
this.recentHeaderNonce = new U256(0);
this.recentBodyNonce = new U256(0);
this.log = false;
this.networkId = networkId;
this.localKey = EC.genKeyPair();
}
connect() {
if (this.socket) this.socket.destroy();
this.socket = new net.Socket();
this.bindListeners();
this.log('connecting...');
this.connectionStatus = 'pending';
return new Promise((resolve, reject) => {
this.resolveConnection = resolve;
this.rejectConnection = reject;
this.socket.connect(PIPE_PATH);
});
}
connect() {
try {
this.forceDisconnect = false
this.socket = new net.Socket()
this.bindSocket()
this.socket.connect({ host: this.device.host, port: this.device.port }, () => {
this.didConnect()
this.emit('connected')
})
} catch (err) {
this.socketClosed(err)
}
}
constructor(address,params){
this.type = "socket"
this.stream = new Socket();
this.stream.setTimeout(params.timeout)
this.connected = false
this.params = params
this.address = address
this.receive_buffer = ""
this.on_error_called = false
}
constructor (soc, port, host) {
super(soc)
const socket = new net.Socket()
socket.on('error', err => this.setState(FinalState, err))
socket.connect(port, host, () => {
socket.removeAllListeners('error')
delete this.socket
this.setState(ServerHello, socket)
})
this.socket = socket
}