@leofcoin/peernet 1.1.53 → 1.1.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/exports/browser/{client-c8558012.js → client-d602421d.js} +25 -1
- package/exports/browser/discovery/peer-discovery.d.ts +7 -0
- package/exports/browser/errors/errors.d.ts +3 -0
- package/exports/browser/handlers/data.d.ts +2 -0
- package/exports/browser/handlers/message.d.ts +30 -0
- package/exports/browser/{index-ed6cbdf7.js → index-ba1b3977.js} +1 -1
- package/exports/browser/messages/chat.d.ts +6 -0
- package/exports/browser/messages/data-response.d.ts +6 -0
- package/exports/browser/messages/data.d.ts +10 -0
- package/exports/browser/messages/dht-response.d.ts +6 -0
- package/exports/browser/messages/dht.d.ts +14 -0
- package/exports/browser/messages/file.d.ts +10 -0
- package/exports/browser/messages/peer-response.d.ts +6 -0
- package/exports/browser/messages/peer.d.ts +6 -0
- package/exports/browser/messages/peernet.d.ts +6 -0
- package/exports/browser/messages/ps.d.ts +6 -0
- package/exports/browser/messages/request.d.ts +6 -0
- package/exports/browser/messages/response.d.ts +6 -0
- package/exports/browser/{messages-35d069e1.js → messages-dd1ad11c.js} +1 -1
- package/exports/browser/messages.d.ts +12 -0
- package/exports/browser/{peernet-d40478c5.js → peernet-d5023a29.js} +16 -13
- package/exports/browser/peernet.js +1 -1
- package/exports/browser/proto/chat-message.proto.d.ts +7 -0
- package/exports/browser/proto/data-response.proto.d.ts +5 -0
- package/exports/browser/proto/data.proto.d.ts +5 -0
- package/exports/browser/proto/dht-response.proto.d.ts +5 -0
- package/exports/browser/proto/dht.proto.d.ts +5 -0
- package/exports/browser/proto/file.proto.d.ts +6 -0
- package/exports/browser/proto/peer-response.proto.d.ts +4 -0
- package/exports/browser/proto/peer.proto.d.ts +4 -0
- package/exports/browser/proto/peernet.proto.d.ts +8 -0
- package/exports/browser/proto/ps.proto.d.ts +5 -0
- package/exports/browser/proto/request.proto.d.ts +5 -0
- package/exports/browser/proto/response.proto.d.ts +4 -0
- package/exports/browser/utils/utils.d.ts +7 -0
- package/exports/peernet.js +1 -1
- package/exports/types/discovery/peer-discovery.d.ts +7 -0
- package/exports/types/errors/errors.d.ts +3 -0
- package/exports/types/handlers/data.d.ts +2 -0
- package/exports/types/handlers/message.d.ts +30 -0
- package/exports/types/messages/chat.d.ts +6 -0
- package/exports/types/messages/data-response.d.ts +6 -0
- package/exports/types/messages/data.d.ts +10 -0
- package/exports/types/messages/dht-response.d.ts +6 -0
- package/exports/types/messages/dht.d.ts +14 -0
- package/exports/types/messages/file.d.ts +10 -0
- package/exports/types/messages/peer-response.d.ts +6 -0
- package/exports/types/messages/peer.d.ts +6 -0
- package/exports/types/messages/peernet.d.ts +6 -0
- package/exports/types/messages/ps.d.ts +6 -0
- package/exports/types/messages/request.d.ts +6 -0
- package/exports/types/messages/response.d.ts +6 -0
- package/exports/types/messages.d.ts +12 -0
- package/exports/types/proto/chat-message.proto.d.ts +7 -0
- package/exports/types/proto/data-response.proto.d.ts +5 -0
- package/exports/types/proto/data.proto.d.ts +5 -0
- package/exports/types/proto/dht-response.proto.d.ts +5 -0
- package/exports/types/proto/dht.proto.d.ts +5 -0
- package/exports/types/proto/file.proto.d.ts +6 -0
- package/exports/types/proto/peer-response.proto.d.ts +4 -0
- package/exports/types/proto/peer.proto.d.ts +4 -0
- package/exports/types/proto/peernet.proto.d.ts +8 -0
- package/exports/types/proto/ps.proto.d.ts +5 -0
- package/exports/types/proto/request.proto.d.ts +5 -0
- package/exports/types/proto/response.proto.d.ts +4 -0
- package/exports/types/utils/utils.d.ts +7 -0
- package/package.json +1 -1
- package/src/peernet.ts +1 -1
|
@@ -323,6 +323,30 @@ base(ALPHABET);
|
|
|
323
323
|
|
|
324
324
|
const fromBase58 = (string) => base58$1.decode(string);
|
|
325
325
|
|
|
326
|
+
// todo only one star needed, no need to have one for each network
|
|
327
|
+
// unless we change anything to the star protocoll
|
|
328
|
+
// version diferences should be handled in the chain
|
|
329
|
+
// maybe a good way to handle could be in p2pt-swarm
|
|
330
|
+
var networks = {
|
|
331
|
+
leofcoin: {
|
|
332
|
+
mainnet: {
|
|
333
|
+
// ports don't really matter since it is favorable to have it begind a ngninx proxy but if we change something to the proto it's easier maybe?
|
|
334
|
+
port: 44444,
|
|
335
|
+
// todo a versionhash would be nice to have as a double check?
|
|
336
|
+
versionHash: '0',
|
|
337
|
+
// a short description identifying the version
|
|
338
|
+
description: 'Main net current version',
|
|
339
|
+
stars: ['wss://star.leofcoin.org'] // todo webrtc and bittorent stars
|
|
340
|
+
},
|
|
341
|
+
peach: {
|
|
342
|
+
port: 44444,
|
|
343
|
+
description: 'Main testnet: latest step before merging into main',
|
|
344
|
+
versionHash: '1',
|
|
345
|
+
stars: ['wss://star.leofcoin.org'] // todo webrtc and bittorent stars
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
|
|
326
350
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f();}else if(typeof define==="function"&&define.amd){define([],f);}else {var g;if(typeof window!=="undefined"){g=window;}else if(typeof global!=="undefined"){g=global;}else if(typeof self!=="undefined"){g=self;}else {g=this;}g.P2PT = f();}})(function(){return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t);}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
327
351
|
|
|
328
352
|
var WebSocketTracker = require('bittorrent-tracker/lib/client/websocket-tracker.js');
|
|
@@ -10645,7 +10669,7 @@ class P2PTClient extends P2PT {
|
|
|
10645
10669
|
get discovered() {
|
|
10646
10670
|
return this.#discovered || {};
|
|
10647
10671
|
}
|
|
10648
|
-
constructor(peerId, networkVersion = 'leofcoin:peach', stars =
|
|
10672
|
+
constructor(peerId, networkVersion = 'leofcoin:peach', stars = networks.leofcoin.peach.stars) {
|
|
10649
10673
|
// @ts-ignore
|
|
10650
10674
|
super(stars, networkVersion, fromBase58(peerId));
|
|
10651
10675
|
this.stars = stars;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default class MessageHandler {
|
|
2
|
+
constructor(network: any);
|
|
3
|
+
network: any;
|
|
4
|
+
/**
|
|
5
|
+
* hash and sign message
|
|
6
|
+
*
|
|
7
|
+
* @param {object} message
|
|
8
|
+
* @param {Buffer} message.from peer id
|
|
9
|
+
* @param {Buffer} message.to peer id
|
|
10
|
+
* @param {string} message.data Peernet message
|
|
11
|
+
* (PeernetMessage excluded) encoded as a string
|
|
12
|
+
* @return message
|
|
13
|
+
*/
|
|
14
|
+
hashAndSignMessage(message: {
|
|
15
|
+
from: Buffer;
|
|
16
|
+
to: Buffer;
|
|
17
|
+
data: string;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
from: Buffer;
|
|
20
|
+
to: Buffer;
|
|
21
|
+
data: string;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* @param {String} from - peer id
|
|
25
|
+
* @param {String} to - peer id
|
|
26
|
+
* @param {String|PeernetMessage} data - data encoded message string
|
|
27
|
+
* or the messageNode itself
|
|
28
|
+
*/
|
|
29
|
+
prepareMessage(message: any): Promise<any>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const ChatMessage_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class ChatMessage extends ChatMessage_base {
|
|
3
|
+
constructor(buffer: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const DataMessageResponse_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class DataMessageResponse extends DataMessageResponse_base {
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @extends {CodecFormat}
|
|
3
|
+
*/
|
|
4
|
+
export default class DataMessage {
|
|
5
|
+
/**
|
|
6
|
+
* @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
|
|
7
|
+
*/
|
|
8
|
+
constructor(data: Buffer | string | any | DataMessage);
|
|
9
|
+
get messageName(): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const DHTMessageResponse_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class DHTMessageResponse extends DHTMessageResponse_base {
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const DHTMessage_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
/**
|
|
3
|
+
* @example `
|
|
4
|
+
new DHTMessage(hash, store)
|
|
5
|
+
// store = optional if not set, peernet checks every store
|
|
6
|
+
let message = new DHTMessage('hashmvbs124xcfd...', 'transaction')
|
|
7
|
+
message = new DHTMessage('hashmvbs124xcfd...', 'block')
|
|
8
|
+
`
|
|
9
|
+
*/
|
|
10
|
+
export default class DHTMessage extends DHTMessage_base {
|
|
11
|
+
constructor(data: any);
|
|
12
|
+
get messageName(): string;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @extends {CodecFormat}
|
|
3
|
+
*/
|
|
4
|
+
export default class PeernetFile {
|
|
5
|
+
/**
|
|
6
|
+
* @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
|
|
7
|
+
*/
|
|
8
|
+
constructor(data: Buffer | string | any | DataMessage);
|
|
9
|
+
get messageName(): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const PeerMessageResponse_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class PeerMessageResponse extends PeerMessageResponse_base {
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const PeerMessage_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class PeerMessage extends PeerMessage_base {
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const PeernetMessage_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class PeernetMessage extends PeernetMessage_base {
|
|
3
|
+
constructor(buffer: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const PsMessage_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class PsMessage extends PsMessage_base {
|
|
3
|
+
constructor(buffer: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const RequestMessage_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class RequestMessage extends RequestMessage_base {
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const ResponseMessage_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class ResponseMessage extends ResponseMessage_base {
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { default as PeernetMessage } from "./messages/peernet.js";
|
|
2
|
+
export { default as DHTMessage } from "./messages/dht.js";
|
|
3
|
+
export { default as DHTMessageResponse } from "./messages/dht-response.js";
|
|
4
|
+
export { default as DataMessage } from "./messages/data.js";
|
|
5
|
+
export { default as PsMessage } from "./messages/ps.js";
|
|
6
|
+
export { default as PeerMessage } from "./messages/peer.js";
|
|
7
|
+
export { default as RequestMessage } from "./messages/request.js";
|
|
8
|
+
export { default as ResponseMessage } from "./messages/response.js";
|
|
9
|
+
export { default as PeerMessageResponse } from "./messages/peer-response.js";
|
|
10
|
+
export { default as DataMessageResponse } from "./messages/data-response.js";
|
|
11
|
+
export { default as ChatMessage } from "./messages/chat.js";
|
|
12
|
+
export { default as PeernetFile } from "./messages/file.js";
|
|
@@ -38,15 +38,18 @@ class LittlePubSub {
|
|
|
38
38
|
if (this.subscribers[event].handlers.length === 0)
|
|
39
39
|
delete this.subscribers[event];
|
|
40
40
|
}
|
|
41
|
-
publish(event,
|
|
41
|
+
publish(event, value) {
|
|
42
|
+
// always set value even when having no subscribers
|
|
42
43
|
if (!this.hasSubscribers(event))
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
this.subscribers[event] = {
|
|
45
|
+
handlers: []
|
|
46
|
+
};
|
|
47
|
+
const oldValue = this.subscribers[event]?.value;
|
|
48
|
+
this.subscribers[event].value = value;
|
|
49
|
+
if (this.verbose || oldValue !== value)
|
|
50
|
+
for (const handler of this.subscribers[event].handlers) {
|
|
51
|
+
handler(value, oldValue);
|
|
52
|
+
}
|
|
50
53
|
}
|
|
51
54
|
once(event) {
|
|
52
55
|
return new Promise((resolve) => {
|
|
@@ -6340,7 +6343,7 @@ let LeofcoinStorage$1 = class LeofcoinStorage {
|
|
|
6340
6343
|
this.name = name;
|
|
6341
6344
|
this.root = root;
|
|
6342
6345
|
}
|
|
6343
|
-
async init(
|
|
6346
|
+
async init() {
|
|
6344
6347
|
const importee = await import(globalThis.navigator ? './browser-store.js' : './store.js');
|
|
6345
6348
|
const Store = importee.default;
|
|
6346
6349
|
this.db = new Store(this.name, this.root);
|
|
@@ -20078,7 +20081,7 @@ class Identity {
|
|
|
20078
20081
|
globalThis.peernet.selectedAccount = new TextDecoder().decode(selected);
|
|
20079
20082
|
}
|
|
20080
20083
|
else {
|
|
20081
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-
|
|
20084
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-ba1b3977.js');
|
|
20082
20085
|
const { identity, accounts } = await importee.default(password, this.network);
|
|
20083
20086
|
await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
|
|
20084
20087
|
await globalThis.walletStore.put('version', String(1));
|
|
@@ -20257,7 +20260,7 @@ class Peernet {
|
|
|
20257
20260
|
this.root = options.root;
|
|
20258
20261
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
20259
20262
|
// FolderMessageResponse
|
|
20260
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-
|
|
20263
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-dd1ad11c.js');
|
|
20261
20264
|
/**
|
|
20262
20265
|
* proto Object containing protos
|
|
20263
20266
|
* @type {Object}
|
|
@@ -20342,7 +20345,7 @@ class Peernet {
|
|
|
20342
20345
|
if (this.#starting || this.#started)
|
|
20343
20346
|
return;
|
|
20344
20347
|
this.#starting = true;
|
|
20345
|
-
const importee = await import('./client-
|
|
20348
|
+
const importee = await import('./client-d602421d.js');
|
|
20346
20349
|
/**
|
|
20347
20350
|
* @access public
|
|
20348
20351
|
* @type {PeernetClient}
|
|
@@ -20515,7 +20518,7 @@ class Peernet {
|
|
|
20515
20518
|
}
|
|
20516
20519
|
async requestData(hash, store) {
|
|
20517
20520
|
const providers = await this.providersFor(hash);
|
|
20518
|
-
if (!providers || Object.keys(providers).length === 0)
|
|
20521
|
+
if (!providers || providers && Object.keys(providers).length === 0)
|
|
20519
20522
|
throw nothingFoundError(hash);
|
|
20520
20523
|
debug(`found ${Object.keys(providers).length} provider(s) for ${hash}`);
|
|
20521
20524
|
// get closest peer on earth
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { P as default } from './peernet-
|
|
1
|
+
export { P as default } from './peernet-d5023a29.js';
|
|
2
2
|
import './value-4e80eeeb.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function BufferToUint8Array(data: any): any;
|
|
2
|
+
export function expected(expected: any, actual: any): string;
|
|
3
|
+
export function protoFor(message: any): any;
|
|
4
|
+
export function hasDaemon(): boolean;
|
|
5
|
+
export function https(): boolean;
|
|
6
|
+
export function environment(): string;
|
|
7
|
+
export function target(): any;
|
package/exports/peernet.js
CHANGED
|
@@ -778,7 +778,7 @@ class Peernet {
|
|
|
778
778
|
}
|
|
779
779
|
async requestData(hash, store) {
|
|
780
780
|
const providers = await this.providersFor(hash);
|
|
781
|
-
if (!providers || Object.keys(providers).length === 0)
|
|
781
|
+
if (!providers || providers && Object.keys(providers).length === 0)
|
|
782
782
|
throw nothingFoundError(hash);
|
|
783
783
|
debug(`found ${Object.keys(providers).length} provider(s) for ${hash}`);
|
|
784
784
|
// get closest peer on earth
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default class MessageHandler {
|
|
2
|
+
constructor(network: any);
|
|
3
|
+
network: any;
|
|
4
|
+
/**
|
|
5
|
+
* hash and sign message
|
|
6
|
+
*
|
|
7
|
+
* @param {object} message
|
|
8
|
+
* @param {Buffer} message.from peer id
|
|
9
|
+
* @param {Buffer} message.to peer id
|
|
10
|
+
* @param {string} message.data Peernet message
|
|
11
|
+
* (PeernetMessage excluded) encoded as a string
|
|
12
|
+
* @return message
|
|
13
|
+
*/
|
|
14
|
+
hashAndSignMessage(message: {
|
|
15
|
+
from: Buffer;
|
|
16
|
+
to: Buffer;
|
|
17
|
+
data: string;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
from: Buffer;
|
|
20
|
+
to: Buffer;
|
|
21
|
+
data: string;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* @param {String} from - peer id
|
|
25
|
+
* @param {String} to - peer id
|
|
26
|
+
* @param {String|PeernetMessage} data - data encoded message string
|
|
27
|
+
* or the messageNode itself
|
|
28
|
+
*/
|
|
29
|
+
prepareMessage(message: any): Promise<any>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const ChatMessage_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class ChatMessage extends ChatMessage_base {
|
|
3
|
+
constructor(buffer: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const DataMessageResponse_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class DataMessageResponse extends DataMessageResponse_base {
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @extends {CodecFormat}
|
|
3
|
+
*/
|
|
4
|
+
export default class DataMessage {
|
|
5
|
+
/**
|
|
6
|
+
* @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
|
|
7
|
+
*/
|
|
8
|
+
constructor(data: Buffer | string | any | DataMessage);
|
|
9
|
+
get messageName(): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const DHTMessageResponse_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class DHTMessageResponse extends DHTMessageResponse_base {
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const DHTMessage_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
/**
|
|
3
|
+
* @example `
|
|
4
|
+
new DHTMessage(hash, store)
|
|
5
|
+
// store = optional if not set, peernet checks every store
|
|
6
|
+
let message = new DHTMessage('hashmvbs124xcfd...', 'transaction')
|
|
7
|
+
message = new DHTMessage('hashmvbs124xcfd...', 'block')
|
|
8
|
+
`
|
|
9
|
+
*/
|
|
10
|
+
export default class DHTMessage extends DHTMessage_base {
|
|
11
|
+
constructor(data: any);
|
|
12
|
+
get messageName(): string;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @extends {CodecFormat}
|
|
3
|
+
*/
|
|
4
|
+
export default class PeernetFile {
|
|
5
|
+
/**
|
|
6
|
+
* @param {Buffer|String|Object|DataMessage} data - The data needed to create the DataMessage
|
|
7
|
+
*/
|
|
8
|
+
constructor(data: Buffer | string | any | DataMessage);
|
|
9
|
+
get messageName(): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const PeerMessageResponse_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class PeerMessageResponse extends PeerMessageResponse_base {
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const PeerMessage_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class PeerMessage extends PeerMessage_base {
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const PeernetMessage_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class PeernetMessage extends PeernetMessage_base {
|
|
3
|
+
constructor(buffer: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const PsMessage_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class PsMessage extends PsMessage_base {
|
|
3
|
+
constructor(buffer: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const RequestMessage_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class RequestMessage extends RequestMessage_base {
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const ResponseMessage_base: typeof import("../../node_modules/@leofcoin/codec-format-interface/dist/codec-format-interface.js").default;
|
|
2
|
+
export default class ResponseMessage extends ResponseMessage_base {
|
|
3
|
+
constructor(data: any);
|
|
4
|
+
get messageName(): string;
|
|
5
|
+
}
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { default as PeernetMessage } from "./messages/peernet.js";
|
|
2
|
+
export { default as DHTMessage } from "./messages/dht.js";
|
|
3
|
+
export { default as DHTMessageResponse } from "./messages/dht-response.js";
|
|
4
|
+
export { default as DataMessage } from "./messages/data.js";
|
|
5
|
+
export { default as PsMessage } from "./messages/ps.js";
|
|
6
|
+
export { default as PeerMessage } from "./messages/peer.js";
|
|
7
|
+
export { default as RequestMessage } from "./messages/request.js";
|
|
8
|
+
export { default as ResponseMessage } from "./messages/response.js";
|
|
9
|
+
export { default as PeerMessageResponse } from "./messages/peer-response.js";
|
|
10
|
+
export { default as DataMessageResponse } from "./messages/data-response.js";
|
|
11
|
+
export { default as ChatMessage } from "./messages/chat.js";
|
|
12
|
+
export { default as PeernetFile } from "./messages/file.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function BufferToUint8Array(data: any): any;
|
|
2
|
+
export function expected(expected: any, actual: any): string;
|
|
3
|
+
export function protoFor(message: any): any;
|
|
4
|
+
export function hasDaemon(): boolean;
|
|
5
|
+
export function https(): boolean;
|
|
6
|
+
export function environment(): string;
|
|
7
|
+
export function target(): any;
|
package/package.json
CHANGED
package/src/peernet.ts
CHANGED
|
@@ -473,7 +473,7 @@ export default class Peernet {
|
|
|
473
473
|
|
|
474
474
|
async requestData(hash, store) {
|
|
475
475
|
const providers = await this.providersFor(hash)
|
|
476
|
-
if (!providers || Object.keys(providers).length === 0) throw nothingFoundError(hash)
|
|
476
|
+
if (!providers || providers && Object.keys(providers).length === 0) throw nothingFoundError(hash)
|
|
477
477
|
debug(`found ${Object.keys(providers).length} provider(s) for ${hash}`)
|
|
478
478
|
// get closest peer on earth
|
|
479
479
|
const closestPeer: DHTProvider = Object.values(providers)[0];
|