@libp2p/floodsub 8.0.12 → 8.0.13-97ab31c0c
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/dist/index.min.js +9 -9
- package/dist/src/config.d.ts +0 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +0 -2
- package/dist/src/config.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -7
- package/dist/src/index.js.map +1 -1
- package/package.json +10 -10
- package/src/config.ts +0 -4
- package/src/index.ts +7 -8
- package/dist/typedoc-urls.json +0 -11
package/dist/src/config.d.ts
CHANGED
package/dist/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,oBAAoB,CAAA"}
|
package/dist/src/config.js
CHANGED
package/dist/src/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,CAAA"}
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;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,IAAI,GAAE,YAAiB,GAAG,CAAC,UAAU,EAAE,kBAAkB,KAAK,MAAM,CAE7F"}
|
package/dist/src/index.js
CHANGED
|
@@ -23,19 +23,17 @@
|
|
|
23
23
|
*
|
|
24
24
|
* node.pubsub.subscribe('fruit')
|
|
25
25
|
* node.pubsub.addEventListener('message', (evt) => {
|
|
26
|
-
* console.log(evt)
|
|
26
|
+
* console.this.log(evt)
|
|
27
27
|
* })
|
|
28
28
|
*
|
|
29
29
|
* node.pubsub.publish('fruit', new TextEncoder().encode('banana'))
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
import { logger } from '@libp2p/logger';
|
|
33
32
|
import { PubSubBaseProtocol } from '@libp2p/pubsub';
|
|
34
33
|
import { toString } from 'uint8arrays/to-string';
|
|
35
34
|
import { SimpleTimeCache } from './cache.js';
|
|
36
35
|
import { multicodec } from './config.js';
|
|
37
36
|
import { RPC } from './message/rpc.js';
|
|
38
|
-
const log = logger('libp2p:floodsub');
|
|
39
37
|
export { multicodec };
|
|
40
38
|
/**
|
|
41
39
|
* FloodSub (aka dumbsub is an implementation of pubsub focused on
|
|
@@ -50,6 +48,7 @@ export class FloodSub extends PubSubBaseProtocol {
|
|
|
50
48
|
canRelayMessage: true,
|
|
51
49
|
multicodecs: [multicodec]
|
|
52
50
|
});
|
|
51
|
+
this.log = components.logger.forComponent('libp2p:floodsub');
|
|
53
52
|
/**
|
|
54
53
|
* Cache of seen messages
|
|
55
54
|
*
|
|
@@ -98,19 +97,19 @@ export class FloodSub extends PubSubBaseProtocol {
|
|
|
98
97
|
const peers = this.getSubscribers(message.topic);
|
|
99
98
|
const recipients = [];
|
|
100
99
|
if (peers == null || peers.length === 0) {
|
|
101
|
-
log('no peers are subscribed to topic %s', message.topic);
|
|
100
|
+
this.log('no peers are subscribed to topic %s', message.topic);
|
|
102
101
|
return { recipients };
|
|
103
102
|
}
|
|
104
103
|
peers.forEach(id => {
|
|
105
104
|
if (this.components.peerId.equals(id)) {
|
|
106
|
-
log('not sending message on topic %s to myself', message.topic);
|
|
105
|
+
this.log('not sending message on topic %s to myself', message.topic);
|
|
107
106
|
return;
|
|
108
107
|
}
|
|
109
108
|
if (id.equals(from)) {
|
|
110
|
-
log('not sending message on topic %s to sender %p', message.topic, id);
|
|
109
|
+
this.log('not sending message on topic %s to sender %p', message.topic, id);
|
|
111
110
|
return;
|
|
112
111
|
}
|
|
113
|
-
log('publish msgs on topics %s %p', message.topic, id);
|
|
112
|
+
this.log('publish msgs on topics %s %p', message.topic, id);
|
|
114
113
|
recipients.push(id);
|
|
115
114
|
this.send(id, { messages: [message] });
|
|
116
115
|
});
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,kBAAkB,EAAyB,MAAM,gBAAgB,CAAA;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAKtC,OAAO,EAAE,UAAU,EAAE,CAAA;AAUrB;;;;GAIG;AACH,MAAM,OAAO,QAAS,SAAQ,kBAAkB;IACvC,SAAS,CAA0B;IAE1C,YAAa,UAA8B,EAAE,IAAmB;QAC9D,KAAK,CAAC,UAAU,EAAE;YAChB,GAAG,IAAI;YACP,eAAe,EAAE,IAAI;YACrB,WAAW,EAAE,CAAC,UAAU,CAAC;SAC1B,CAAC,CAAA;QAEF,IA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floodsub, also known as pubsub-flood or just dumbsub, this implementation of pubsub focused on delivering an API for Publish/Subscribe, but with no CastTree Forming (it just floods the network).",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/pubsub-floodsub#readme",
|
|
@@ -55,23 +55,23 @@
|
|
|
55
55
|
"test:electron-main": "aegir test -t electron-main"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@libp2p/interface": "
|
|
59
|
-
"@libp2p/
|
|
60
|
-
"@libp2p/pubsub": "^8.0.9",
|
|
58
|
+
"@libp2p/interface": "0.1.6-97ab31c0c",
|
|
59
|
+
"@libp2p/pubsub": "8.0.10-97ab31c0c",
|
|
61
60
|
"protons-runtime": "^5.0.0",
|
|
62
61
|
"uint8arraylist": "^2.4.3",
|
|
63
62
|
"uint8arrays": "^4.0.6"
|
|
64
63
|
},
|
|
65
64
|
"devDependencies": {
|
|
66
|
-
"@libp2p/interface-compliance-tests": "
|
|
67
|
-
"@libp2p/
|
|
68
|
-
"@libp2p/peer-
|
|
69
|
-
"@
|
|
65
|
+
"@libp2p/interface-compliance-tests": "4.1.5-97ab31c0c",
|
|
66
|
+
"@libp2p/logger": "3.1.0-97ab31c0c",
|
|
67
|
+
"@libp2p/peer-collections": "4.0.8-97ab31c0c",
|
|
68
|
+
"@libp2p/peer-id-factory": "3.0.8-97ab31c0c",
|
|
69
|
+
"@multiformats/multiaddr": "^12.1.10",
|
|
70
70
|
"@types/sinon": "^17.0.0",
|
|
71
71
|
"aegir": "^41.0.2",
|
|
72
|
-
"multiformats": "^12.
|
|
72
|
+
"multiformats": "^12.1.3",
|
|
73
73
|
"p-wait-for": "^5.0.2",
|
|
74
|
-
"protons": "^7.0
|
|
74
|
+
"protons": "^7.3.0",
|
|
75
75
|
"sinon": "^17.0.0"
|
|
76
76
|
}
|
|
77
77
|
}
|
package/src/config.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -23,14 +23,13 @@
|
|
|
23
23
|
*
|
|
24
24
|
* node.pubsub.subscribe('fruit')
|
|
25
25
|
* node.pubsub.addEventListener('message', (evt) => {
|
|
26
|
-
* console.log(evt)
|
|
26
|
+
* console.this.log(evt)
|
|
27
27
|
* })
|
|
28
28
|
*
|
|
29
29
|
* node.pubsub.publish('fruit', new TextEncoder().encode('banana'))
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
-
import { logger } from '@libp2p/logger'
|
|
34
33
|
import { PubSubBaseProtocol, type PubSubComponents } from '@libp2p/pubsub'
|
|
35
34
|
import { toString } from 'uint8arrays/to-string'
|
|
36
35
|
import { SimpleTimeCache } from './cache.js'
|
|
@@ -40,8 +39,6 @@ import type { PeerId } from '@libp2p/interface/peer-id'
|
|
|
40
39
|
import type { PubSubInit, Message, PubSubRPC, PubSubRPCMessage, PublishResult, PubSub } from '@libp2p/interface/pubsub'
|
|
41
40
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
42
41
|
|
|
43
|
-
const log = logger('libp2p:floodsub')
|
|
44
|
-
|
|
45
42
|
export { multicodec }
|
|
46
43
|
|
|
47
44
|
export interface FloodSubInit extends PubSubInit {
|
|
@@ -67,6 +64,8 @@ export class FloodSub extends PubSubBaseProtocol {
|
|
|
67
64
|
multicodecs: [multicodec]
|
|
68
65
|
})
|
|
69
66
|
|
|
67
|
+
this.log = components.logger.forComponent('libp2p:floodsub')
|
|
68
|
+
|
|
70
69
|
/**
|
|
71
70
|
* Cache of seen messages
|
|
72
71
|
*
|
|
@@ -125,22 +124,22 @@ export class FloodSub extends PubSubBaseProtocol {
|
|
|
125
124
|
const recipients: PeerId[] = []
|
|
126
125
|
|
|
127
126
|
if (peers == null || peers.length === 0) {
|
|
128
|
-
log('no peers are subscribed to topic %s', message.topic)
|
|
127
|
+
this.log('no peers are subscribed to topic %s', message.topic)
|
|
129
128
|
return { recipients }
|
|
130
129
|
}
|
|
131
130
|
|
|
132
131
|
peers.forEach(id => {
|
|
133
132
|
if (this.components.peerId.equals(id)) {
|
|
134
|
-
log('not sending message on topic %s to myself', message.topic)
|
|
133
|
+
this.log('not sending message on topic %s to myself', message.topic)
|
|
135
134
|
return
|
|
136
135
|
}
|
|
137
136
|
|
|
138
137
|
if (id.equals(from)) {
|
|
139
|
-
log('not sending message on topic %s to sender %p', message.topic, id)
|
|
138
|
+
this.log('not sending message on topic %s to sender %p', message.topic, id)
|
|
140
139
|
return
|
|
141
140
|
}
|
|
142
141
|
|
|
143
|
-
log('publish msgs on topics %s %p', message.topic, id)
|
|
142
|
+
this.log('publish msgs on topics %s %p', message.topic, id)
|
|
144
143
|
|
|
145
144
|
recipients.push(id)
|
|
146
145
|
this.send(id, { messages: [message] })
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"FloodSub": "https://libp2p.github.io/js-libp2p/classes/_libp2p_floodsub.FloodSub.html",
|
|
3
|
-
".:FloodSub": "https://libp2p.github.io/js-libp2p/classes/_libp2p_floodsub.FloodSub.html",
|
|
4
|
-
"FloodSubComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.FloodSubComponents.html",
|
|
5
|
-
".:FloodSubComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.FloodSubComponents.html",
|
|
6
|
-
"FloodSubInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.FloodSubInit.html",
|
|
7
|
-
".:FloodSubInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_floodsub.FloodSubInit.html",
|
|
8
|
-
"multicodec": "https://libp2p.github.io/js-libp2p/variables/_libp2p_floodsub.multicodec.html",
|
|
9
|
-
"floodsub": "https://libp2p.github.io/js-libp2p/functions/_libp2p_floodsub.floodsub-1.html",
|
|
10
|
-
".:floodsub": "https://libp2p.github.io/js-libp2p/functions/_libp2p_floodsub.floodsub-1.html"
|
|
11
|
-
}
|