Compare commits
4 Commits
v0.1.0-dev
...
v0.1.0-dev
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | 07459357fc | |
Derrick Hammer | 905c35aed1 | |
Derrick Hammer | dfe9e3f082 | |
Derrick Hammer | 90c0614773 |
|
@ -1,3 +1,5 @@
|
|||
# [0.1.0-develop.32](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.31...v0.1.0-develop.32) (2023-09-02)
|
||||
|
||||
# [0.1.0-develop.31](https://git.lumeweb.com/LumeWeb/libs5/compare/v0.1.0-develop.30...v0.1.0-develop.31) (2023-09-02)
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@lumeweb/libs5",
|
||||
"version": "0.1.0-develop.31",
|
||||
"version": "0.1.0-develop.32",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@lumeweb/libs5",
|
||||
"version": "0.1.0-develop.31",
|
||||
"version": "0.1.0-develop.32",
|
||||
"dependencies": {
|
||||
"@noble/curves": "^1.1.0",
|
||||
"@noble/hashes": "^1.3.1",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@lumeweb/libs5",
|
||||
"version": "0.1.0-develop.31",
|
||||
"version": "0.1.0-develop.32",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
"repository": {
|
||||
|
|
|
@ -69,6 +69,10 @@ export class S5Node {
|
|||
await p2p.start();
|
||||
}
|
||||
|
||||
public async stop() {
|
||||
await this.services.p2p.stop();
|
||||
}
|
||||
|
||||
async readStorageLocationsFromDB(
|
||||
hash: Multihash,
|
||||
): Promise<Map<number, Map<string, Map<number, any>>>> {
|
||||
|
|
|
@ -97,6 +97,9 @@ export class P2PService extends EventEmitter {
|
|||
this.connectToNode([new URL(p)]);
|
||||
}
|
||||
}
|
||||
async stop() {
|
||||
[...this.node.services.p2p.peers.values()].forEach((peer) => peer.end());
|
||||
}
|
||||
|
||||
async onNewPeer(peer: Peer, verifyId: boolean): Promise<void> {
|
||||
peer.challenge = crypto.randomBytes(32);
|
||||
|
|
|
@ -38,4 +38,6 @@ export abstract class BasePeer implements Peer {
|
|||
logger,
|
||||
}: { onDone?: any; onError?: (...args: any[]) => void; logger: Logger },
|
||||
): void;
|
||||
|
||||
abstract end(): void;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import * as console from "console";
|
|||
import { BasePeer } from "#transports/base.js";
|
||||
|
||||
export class TcpPeer extends BasePeer implements Peer {
|
||||
declare _socket: net.Socket;
|
||||
|
||||
sendMessage(message: Uint8Array): void {
|
||||
this._socket.write(message);
|
||||
}
|
||||
|
@ -59,6 +61,9 @@ export class TcpPeer extends BasePeer implements Peer {
|
|||
this._socket.on("error", onError);
|
||||
}
|
||||
}
|
||||
end(): void {
|
||||
this._socket.end();
|
||||
}
|
||||
|
||||
public static async connect(uri: URL): Promise<net.Socket> {
|
||||
const host = uri.hostname;
|
||||
|
|
|
@ -42,6 +42,9 @@ export class WebSocketPeer extends BasePeer implements Peer {
|
|||
this._socket.addEventListener("error", onError);
|
||||
}
|
||||
}
|
||||
end(): void {
|
||||
this._socket.end();
|
||||
}
|
||||
|
||||
public static async connect(uri: URL): Promise<WebSocket> {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
|
|
@ -28,6 +28,7 @@ export interface Peer {
|
|||
): void;
|
||||
|
||||
renderLocationUri(): string;
|
||||
end(): void;
|
||||
}
|
||||
|
||||
export type PeerConstructorOptions = { socket: any; uris?: URL[] };
|
||||
|
|
Loading…
Reference in New Issue