@leofcoin/peernet 0.9.12 → 0.10.0

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.
@@ -33,10 +33,17 @@ var MultiWallet__default = /*#__PURE__*/_interopDefaultLegacy(MultiWallet);
33
33
  class PeernetPeer {
34
34
  constructor(id, connection) {
35
35
  this._events = {};
36
+ this.bw = {
37
+ up: 0,
38
+ down: 0
39
+ };
36
40
  this.id = id;
37
41
  this.connection = connection;
38
42
 
39
- this.connection.on('data', (message) => pubsub.publish('peernet.data', JSON.parse(message.toString())));
43
+ this.connection.on('data', (message) => {
44
+ this.bw.down += data.length;
45
+ pubsub.publish('peernet.data', JSON.parse(message.toString()));
46
+ });
40
47
  }
41
48
 
42
49
  request(data) {
@@ -62,6 +69,8 @@ class PeernetPeer {
62
69
 
63
70
  write(data) {
64
71
  if (!Buffer.isBuffer(data)) data = Buffer.from(data);
72
+
73
+ this.bw.up += data.length;
65
74
  this.connection.write(data);
66
75
  }
67
76
 
@@ -280,7 +289,7 @@ class LeofcoinStorage$1 {
280
289
 
281
290
  }
282
291
 
283
- var version = "0.9.11";
292
+ var version = "0.9.12";
284
293
 
285
294
  var api$1 = {
286
295
  version: ({send}) => send({client: '@peernet/api/http', version}),
@@ -36,10 +36,17 @@ var MultiWallet__default = /*#__PURE__*/_interopDefaultLegacy(MultiWallet);
36
36
  class PeernetPeer {
37
37
  constructor(id, connection) {
38
38
  this._events = {};
39
+ this.bw = {
40
+ up: 0,
41
+ down: 0
42
+ };
39
43
  this.id = id;
40
44
  this.connection = connection;
41
45
 
42
- this.connection.on('data', (message) => pubsub.publish('peernet.data', JSON.parse(message.toString())));
46
+ this.connection.on('data', (message) => {
47
+ this.bw.down += data.length;
48
+ pubsub.publish('peernet.data', JSON.parse(message.toString()));
49
+ });
43
50
  }
44
51
 
45
52
  request(data) {
@@ -65,6 +72,8 @@ class PeernetPeer {
65
72
 
66
73
  write(data) {
67
74
  if (!Buffer.isBuffer(data)) data = Buffer.from(data);
75
+
76
+ this.bw.up += data.length;
68
77
  this.connection.write(data);
69
78
  }
70
79
 
@@ -283,7 +292,7 @@ class LeofcoinStorage$1 {
283
292
 
284
293
  }
285
294
 
286
- var version = "0.9.11";
295
+ var version = "0.9.12";
287
296
 
288
297
  var api$1 = {
289
298
  version: ({send}) => send({client: '@peernet/api/http', version}),
@@ -16,10 +16,17 @@ import MultiWallet from '@leofcoin/multi-wallet';
16
16
  class PeernetPeer {
17
17
  constructor(id, connection) {
18
18
  this._events = {};
19
+ this.bw = {
20
+ up: 0,
21
+ down: 0,
22
+ };
19
23
  this.id = id;
20
24
  this.connection = connection;
21
25
 
22
- this.connection.on('data', (message) => pubsub.publish('peernet.data', JSON.parse(message.toString())));
26
+ this.connection.on('data', (message) => {
27
+ this.bw.down += data.length;
28
+ pubsub.publish('peernet.data', JSON.parse(message.toString()));
29
+ });
23
30
  }
24
31
 
25
32
  request(data) {
@@ -45,6 +52,8 @@ class PeernetPeer {
45
52
 
46
53
  write(data) {
47
54
  if (!Buffer.isBuffer(data)) data = Buffer.from(data);
55
+
56
+ this.bw.up += data.length;
48
57
  this.connection.write(data);
49
58
  }
50
59
 
@@ -263,7 +272,7 @@ class LeofcoinStorage$1 {
263
272
 
264
273
  }
265
274
 
266
- var version = "0.9.11";
275
+ var version = "0.9.12";
267
276
 
268
277
  var api$1 = {
269
278
  version: ({send}) => send({client: '@peernet/api/http', version}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/peernet",
3
- "version": "0.9.12",
3
+ "version": "0.10.0",
4
4
  "description": "",
5
5
  "main": "dist/commonjs/peernet.js",
6
6
  "module": "dist/module/peernet.js",
package/src/peer.js CHANGED
@@ -1,10 +1,17 @@
1
1
  export default class PeernetPeer {
2
2
  constructor(id, connection) {
3
3
  this._events = {}
4
+ this.bw = {
5
+ up: 0,
6
+ down: 0,
7
+ }
4
8
  this.id = id
5
9
  this.connection = connection
6
10
 
7
- this.connection.on('data', (message) => pubsub.publish('peernet.data', JSON.parse(message.toString())))
11
+ this.connection.on('data', (message) => {
12
+ this.bw.down += data.length
13
+ pubsub.publish('peernet.data', JSON.parse(message.toString()))
14
+ })
8
15
  }
9
16
 
10
17
  request(data) {
@@ -30,6 +37,8 @@ export default class PeernetPeer {
30
37
 
31
38
  write(data) {
32
39
  if (!Buffer.isBuffer(data)) data = Buffer.from(data)
40
+
41
+ this.bw.up += data.length
33
42
  this.connection.write(data)
34
43
  }
35
44