@libp2p/interface 0.0.1-daeb43d8 → 0.0.1-e9cafd3d

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.
@@ -10,31 +10,9 @@ export interface ConnectionTimeline {
10
10
  close?: number;
11
11
  }
12
12
  /**
13
- * Outbound conections are opened by the local node, inbound streams are opened by the remote
13
+ * Outbound connections are opened by the local node, inbound streams are opened by the remote
14
14
  */
15
15
  export type Direction = 'inbound' | 'outbound';
16
- export interface ConnectionStat {
17
- /**
18
- * Outbound conections are opened by the local node, inbound streams are opened by the remote
19
- */
20
- direction: Direction;
21
- /**
22
- * Lifecycle times for the connection
23
- */
24
- timeline: ConnectionTimeline;
25
- /**
26
- * Once a multiplexer has been negotiated for this stream, it will be set on the stat object
27
- */
28
- multiplexer?: string;
29
- /**
30
- * Once a connection encrypter has been negotiated for this stream, it will be set on the stat object
31
- */
32
- encryption?: string;
33
- /**
34
- * The current status of the connection
35
- */
36
- status: keyof typeof Status;
37
- }
38
16
  export interface StreamTimeline {
39
17
  /**
40
18
  * A timestamp of when the stream was opened
@@ -57,20 +35,6 @@ export interface StreamTimeline {
57
35
  */
58
36
  reset?: number;
59
37
  }
60
- export interface StreamStat {
61
- /**
62
- * Outbound streams are opened by the local node, inbound streams are opened by the remote
63
- */
64
- direction: Direction;
65
- /**
66
- * Lifecycle times for the stream
67
- */
68
- timeline: StreamTimeline;
69
- /**
70
- * Once a protocol has been negotiated for this stream, it will be set on the stat object
71
- */
72
- protocol?: string;
73
- }
74
38
  /**
75
39
  * A Stream is a data channel between two peers that
76
40
  * can be written to and read from at both ends.
@@ -126,9 +90,17 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
126
90
  */
127
91
  id: string;
128
92
  /**
129
- * Stats about this stream
93
+ * Outbound streams are opened by the local node, inbound streams are opened by the remote
94
+ */
95
+ direction: Direction;
96
+ /**
97
+ * Lifecycle times for the stream
98
+ */
99
+ timeline: StreamTimeline;
100
+ /**
101
+ * Once a protocol has been negotiated for this stream, it will be set on the stat object
130
102
  */
131
- stat: StreamStat;
103
+ protocol?: string;
132
104
  /**
133
105
  * User defined stream metadata
134
106
  */
@@ -149,12 +121,46 @@ export interface NewStreamOptions extends AbortOptions {
149
121
  * between which the connection is made.
150
122
  */
151
123
  export interface Connection {
124
+ /**
125
+ * The unique identifier for this connection
126
+ */
152
127
  id: string;
153
- stat: ConnectionStat;
128
+ /**
129
+ * The address of the remote end of the connection
130
+ */
154
131
  remoteAddr: Multiaddr;
132
+ /**
133
+ * The id of the peer at the remote end of the connection
134
+ */
155
135
  remotePeer: PeerId;
136
+ /**
137
+ * A list of tags applied to this connection
138
+ */
156
139
  tags: string[];
140
+ /**
141
+ * A list of open streams on this connection
142
+ */
157
143
  streams: Stream[];
144
+ /**
145
+ * Outbound conections are opened by the local node, inbound streams are opened by the remote
146
+ */
147
+ direction: Direction;
148
+ /**
149
+ * Lifecycle times for the connection
150
+ */
151
+ timeline: ConnectionTimeline;
152
+ /**
153
+ * Once a multiplexer has been negotiated for this stream, it will be set on the stat object
154
+ */
155
+ multiplexer?: string;
156
+ /**
157
+ * Once a connection encrypter has been negotiated for this stream, it will be set on the stat object
158
+ */
159
+ encryption?: string;
160
+ /**
161
+ * The current status of the connection
162
+ */
163
+ status: keyof typeof Status;
158
164
  newStream: (multicodecs: string | string[], options?: NewStreamOptions) => Promise<Stream>;
159
165
  addStream: (stream: Stream) => void;
160
166
  removeStream: (id: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;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AA2B,CAAA;CACtC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AA6LA,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AAEtD,MAAM,UAAU,YAAY,CAAE,KAAU;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AAChD,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAsMA,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AAEtD,MAAM,UAAU,YAAY,CAAE,KAAU;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AAChD,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { Uint8ArrayList } from 'uint8arraylist';
2
- import type { Direction, Stream, StreamStat } from '../connection/index.js';
2
+ import type { Direction, Stream, StreamTimeline } from '../connection/index.js';
3
3
  import type { Source } from 'it-stream-types';
4
4
  export interface AbstractStreamInit {
5
5
  /**
@@ -26,7 +26,9 @@ export interface AbstractStreamInit {
26
26
  }
27
27
  export declare abstract class AbstractStream implements Stream {
28
28
  id: string;
29
- stat: StreamStat;
29
+ direction: Direction;
30
+ timeline: StreamTimeline;
31
+ protocol?: string;
30
32
  metadata: Record<string, unknown>;
31
33
  source: AsyncGenerator<Uint8ArrayList, void, unknown>;
32
34
  private readonly abortController;
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/stream-muxer/stream.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,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OAAO,CAAC,IAAI,CAAC;IAyGvE;;;OAGG;IACH,UAAU,CAAE,IAAI,EAAE,cAAc,GAAG,IAAI;IAIvC;;;OAGG;IACH,oBAAoB,IAAK,MAAM;IAI/B;;;OAGG;IACH,QAAQ,CAAC,aAAa,IAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE/C;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAE,GAAG,EAAE,cAAc,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE7D;;OAEG;IACH,QAAQ,CAAC,SAAS,IAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3C;;;OAGG;IACH,QAAQ,CAAC,cAAc,IAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAEhD;;;OAGG;IACH,QAAQ,CAAC,aAAa,IAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAChD"}
@@ -17,7 +17,9 @@ function isPromise(res) {
17
17
  }
18
18
  export class AbstractStream {
19
19
  id;
20
- stat;
20
+ direction;
21
+ timeline;
22
+ protocol;
21
23
  metadata;
22
24
  source;
23
25
  abortController;
@@ -39,18 +41,16 @@ export class AbstractStream {
39
41
  this.sinkSunk = false;
40
42
  this.id = init.id;
41
43
  this.metadata = init.metadata ?? {};
42
- this.stat = {
43
- direction: init.direction,
44
- timeline: {
45
- open: Date.now()
46
- }
44
+ this.direction = init.direction;
45
+ this.timeline = {
46
+ open: Date.now()
47
47
  };
48
48
  this.maxDataSize = init.maxDataSize;
49
49
  this.onEnd = init.onEnd;
50
50
  this.source = this.streamSource = pushable({
51
51
  onEnd: () => {
52
52
  // already sent a reset message
53
- if (this.stat.timeline.reset !== null) {
53
+ if (this.timeline.reset !== null) {
54
54
  const res = this.sendCloseRead();
55
55
  if (isPromise(res)) {
56
56
  res.catch(err => {
@@ -68,14 +68,14 @@ export class AbstractStream {
68
68
  if (this.sourceEnded) {
69
69
  return;
70
70
  }
71
- this.stat.timeline.closeRead = Date.now();
71
+ this.timeline.closeRead = Date.now();
72
72
  this.sourceEnded = true;
73
- log.trace('%s stream %s source end - err: %o', this.stat.direction, this.id, err);
73
+ log.trace('%s stream %s source end - err: %o', this.direction, this.id, err);
74
74
  if (err != null && this.endErr == null) {
75
75
  this.endErr = err;
76
76
  }
77
77
  if (this.sinkEnded) {
78
- this.stat.timeline.close = Date.now();
78
+ this.timeline.close = Date.now();
79
79
  if (this.onEnd != null) {
80
80
  this.onEnd(this.endErr);
81
81
  }
@@ -85,14 +85,14 @@ export class AbstractStream {
85
85
  if (this.sinkEnded) {
86
86
  return;
87
87
  }
88
- this.stat.timeline.closeWrite = Date.now();
88
+ this.timeline.closeWrite = Date.now();
89
89
  this.sinkEnded = true;
90
- log.trace('%s stream %s sink end - err: %o', this.stat.direction, this.id, err);
90
+ log.trace('%s stream %s sink end - err: %o', this.direction, this.id, err);
91
91
  if (err != null && this.endErr == null) {
92
92
  this.endErr = err;
93
93
  }
94
94
  if (this.sourceEnded) {
95
- this.stat.timeline.close = Date.now();
95
+ this.timeline.close = Date.now();
96
96
  if (this.onEnd != null) {
97
97
  this.onEnd(this.endErr);
98
98
  }
@@ -100,13 +100,13 @@ export class AbstractStream {
100
100
  }
101
101
  // Close for both Reading and Writing
102
102
  close() {
103
- log.trace('%s stream %s close', this.stat.direction, this.id);
103
+ log.trace('%s stream %s close', this.direction, this.id);
104
104
  this.closeRead();
105
105
  this.closeWrite();
106
106
  }
107
107
  // Close for reading
108
108
  closeRead() {
109
- log.trace('%s stream %s closeRead', this.stat.direction, this.id);
109
+ log.trace('%s stream %s closeRead', this.direction, this.id);
110
110
  if (this.sourceEnded) {
111
111
  return;
112
112
  }
@@ -114,7 +114,7 @@ export class AbstractStream {
114
114
  }
115
115
  // Close for writing
116
116
  closeWrite() {
117
- log.trace('%s stream %s closeWrite', this.stat.direction, this.id);
117
+ log.trace('%s stream %s closeWrite', this.direction, this.id);
118
118
  if (this.sinkEnded) {
119
119
  return;
120
120
  }
@@ -130,13 +130,13 @@ export class AbstractStream {
130
130
  }
131
131
  }
132
132
  catch (err) {
133
- log.trace('%s stream %s error sending close', this.stat.direction, this.id, err);
133
+ log.trace('%s stream %s error sending close', this.direction, this.id, err);
134
134
  }
135
135
  this.onSinkEnd();
136
136
  }
137
137
  // Close for reading and writing (local error)
138
138
  abort(err) {
139
- log.trace('%s stream %s abort', this.stat.direction, this.id, err);
139
+ log.trace('%s stream %s abort', this.direction, this.id, err);
140
140
  // End the source with the passed error
141
141
  this.streamSource.end(err);
142
142
  this.abortController.abort();
@@ -164,7 +164,7 @@ export class AbstractStream {
164
164
  ]);
165
165
  try {
166
166
  source = abortableSource(source, signal);
167
- if (this.stat.direction === 'outbound') { // If initiator, open a new stream
167
+ if (this.direction === 'outbound') { // If initiator, open a new stream
168
168
  const res = this.sendNewStream();
169
169
  if (isPromise(res)) {
170
170
  await res;
@@ -204,19 +204,19 @@ export class AbstractStream {
204
204
  }
205
205
  // Send no more data if this stream was remotely reset
206
206
  if (err.code === ERR_STREAM_RESET) {
207
- log.trace('%s stream %s reset', this.stat.direction, this.id);
207
+ log.trace('%s stream %s reset', this.direction, this.id);
208
208
  }
209
209
  else {
210
- log.trace('%s stream %s error', this.stat.direction, this.id, err);
210
+ log.trace('%s stream %s error', this.direction, this.id, err);
211
211
  try {
212
212
  const res = this.sendReset();
213
213
  if (isPromise(res)) {
214
214
  await res;
215
215
  }
216
- this.stat.timeline.reset = Date.now();
216
+ this.timeline.reset = Date.now();
217
217
  }
218
218
  catch (err) {
219
- log.trace('%s stream %s error sending reset', this.stat.direction, this.id, err);
219
+ log.trace('%s stream %s error sending reset', this.direction, this.id, err);
220
220
  }
221
221
  }
222
222
  this.streamSource.end(err);
@@ -233,7 +233,7 @@ export class AbstractStream {
233
233
  }
234
234
  }
235
235
  catch (err) {
236
- log.trace('%s stream %s error sending close', this.stat.direction, this.id, err);
236
+ log.trace('%s stream %s error sending close', this.direction, this.id, err);
237
237
  }
238
238
  this.onSinkEnd();
239
239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G,EAAE;oBACZ,GAAG,CAAC,KAAK,CAAC,kCAAkC,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;iBAC5E;aACF;YAED,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAC1B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;YAEnB,MAAM,GAAG,CAAA;SACV;gBAAS;YACR,MAAM,CAAC,KAAK,EAAE,CAAA;SACf;QAED,IAAI;YACF,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;YAEjC,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE;gBAClB,MAAM,GAAG,CAAA;aACV;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,GAAG,CAAC,KAAK,CAAC,kCAAkC,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;SAC5E;QAED,IAAI,CAAC,SAAS,EAAE,CAAA;IAClB,CAAC;IAED;;;OAGG;IACH,UAAU,CAAE,IAAoB;QAC9B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IAED;;;OAGG;IACH,oBAAoB;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC,cAAc,CAAA;IACzC,CAAC;CA6BF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/interface",
3
- "version": "0.0.1-daeb43d8",
3
+ "version": "0.0.1-e9cafd3d",
4
4
  "description": "The interface implemented by a libp2p node",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/interface#readme",
@@ -171,7 +171,7 @@
171
171
  },
172
172
  "devDependencies": {
173
173
  "@types/sinon": "^10.0.15",
174
- "aegir": "^39.0.10",
174
+ "aegir": "^39.0.13",
175
175
  "sinon": "^15.1.2",
176
176
  "sinon-ts": "^1.0.0"
177
177
  },
@@ -12,37 +12,10 @@ export interface ConnectionTimeline {
12
12
  }
13
13
 
14
14
  /**
15
- * Outbound conections are opened by the local node, inbound streams are opened by the remote
15
+ * Outbound connections are opened by the local node, inbound streams are opened by the remote
16
16
  */
17
17
  export type Direction = 'inbound' | 'outbound'
18
18
 
19
- export interface ConnectionStat {
20
- /**
21
- * Outbound conections are opened by the local node, inbound streams are opened by the remote
22
- */
23
- direction: Direction
24
-
25
- /**
26
- * Lifecycle times for the connection
27
- */
28
- timeline: ConnectionTimeline
29
-
30
- /**
31
- * Once a multiplexer has been negotiated for this stream, it will be set on the stat object
32
- */
33
- multiplexer?: string
34
-
35
- /**
36
- * Once a connection encrypter has been negotiated for this stream, it will be set on the stat object
37
- */
38
- encryption?: string
39
-
40
- /**
41
- * The current status of the connection
42
- */
43
- status: keyof typeof Status
44
- }
45
-
46
19
  export interface StreamTimeline {
47
20
  /**
48
21
  * A timestamp of when the stream was opened
@@ -70,23 +43,6 @@ export interface StreamTimeline {
70
43
  reset?: number
71
44
  }
72
45
 
73
- export interface StreamStat {
74
- /**
75
- * Outbound streams are opened by the local node, inbound streams are opened by the remote
76
- */
77
- direction: Direction
78
-
79
- /**
80
- * Lifecycle times for the stream
81
- */
82
- timeline: StreamTimeline
83
-
84
- /**
85
- * Once a protocol has been negotiated for this stream, it will be set on the stat object
86
- */
87
- protocol?: string
88
- }
89
-
90
46
  /**
91
47
  * A Stream is a data channel between two peers that
92
48
  * can be written to and read from at both ends.
@@ -148,9 +104,19 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
148
104
  id: string
149
105
 
150
106
  /**
151
- * Stats about this stream
107
+ * Outbound streams are opened by the local node, inbound streams are opened by the remote
152
108
  */
153
- stat: StreamStat
109
+ direction: Direction
110
+
111
+ /**
112
+ * Lifecycle times for the stream
113
+ */
114
+ timeline: StreamTimeline
115
+
116
+ /**
117
+ * Once a protocol has been negotiated for this stream, it will be set on the stat object
118
+ */
119
+ protocol?: string
154
120
 
155
121
  /**
156
122
  * User defined stream metadata
@@ -174,13 +140,56 @@ export interface NewStreamOptions extends AbortOptions {
174
140
  * between which the connection is made.
175
141
  */
176
142
  export interface Connection {
143
+ /**
144
+ * The unique identifier for this connection
145
+ */
177
146
  id: string
178
- stat: ConnectionStat
147
+
148
+ /**
149
+ * The address of the remote end of the connection
150
+ */
179
151
  remoteAddr: Multiaddr
152
+
153
+ /**
154
+ * The id of the peer at the remote end of the connection
155
+ */
180
156
  remotePeer: PeerId
157
+
158
+ /**
159
+ * A list of tags applied to this connection
160
+ */
181
161
  tags: string[]
162
+
163
+ /**
164
+ * A list of open streams on this connection
165
+ */
182
166
  streams: Stream[]
183
167
 
168
+ /**
169
+ * Outbound conections are opened by the local node, inbound streams are opened by the remote
170
+ */
171
+ direction: Direction
172
+
173
+ /**
174
+ * Lifecycle times for the connection
175
+ */
176
+ timeline: ConnectionTimeline
177
+
178
+ /**
179
+ * Once a multiplexer has been negotiated for this stream, it will be set on the stat object
180
+ */
181
+ multiplexer?: string
182
+
183
+ /**
184
+ * Once a connection encrypter has been negotiated for this stream, it will be set on the stat object
185
+ */
186
+ encryption?: string
187
+
188
+ /**
189
+ * The current status of the connection
190
+ */
191
+ status: keyof typeof Status
192
+
184
193
  newStream: (multicodecs: string | string[], options?: NewStreamOptions) => Promise<Stream>
185
194
  addStream: (stream: Stream) => void
186
195
  removeStream: (id: string) => void
@@ -4,7 +4,7 @@ import { anySignal } from 'any-signal'
4
4
  import { type Pushable, pushable } from 'it-pushable'
5
5
  import { Uint8ArrayList } from 'uint8arraylist'
6
6
  import { CodeError } from '../errors.js'
7
- import type { Direction, Stream, StreamStat } from '../connection/index.js'
7
+ import type { Direction, Stream, StreamTimeline } from '../connection/index.js'
8
8
  import type { Source } from 'it-stream-types'
9
9
 
10
10
  // const log = logger('libp2p:stream')
@@ -52,7 +52,9 @@ function isPromise (res?: any): res is Promise<void> {
52
52
 
53
53
  export abstract class AbstractStream implements Stream {
54
54
  public id: string
55
- public stat: StreamStat
55
+ public direction: Direction
56
+ public timeline: StreamTimeline
57
+ public protocol?: string
56
58
  public metadata: Record<string, unknown>
57
59
  public source: AsyncGenerator<Uint8ArrayList, void, unknown>
58
60
 
@@ -77,11 +79,9 @@ export abstract class AbstractStream implements Stream {
77
79
 
78
80
  this.id = init.id
79
81
  this.metadata = init.metadata ?? {}
80
- this.stat = {
81
- direction: init.direction,
82
- timeline: {
83
- open: Date.now()
84
- }
82
+ this.direction = init.direction
83
+ this.timeline = {
84
+ open: Date.now()
85
85
  }
86
86
  this.maxDataSize = init.maxDataSize
87
87
  this.onEnd = init.onEnd
@@ -89,7 +89,7 @@ export abstract class AbstractStream implements Stream {
89
89
  this.source = this.streamSource = pushable<Uint8ArrayList>({
90
90
  onEnd: () => {
91
91
  // already sent a reset message
92
- if (this.stat.timeline.reset !== null) {
92
+ if (this.timeline.reset !== null) {
93
93
  const res = this.sendCloseRead()
94
94
 
95
95
  if (isPromise(res)) {
@@ -112,16 +112,16 @@ export abstract class AbstractStream implements Stream {
112
112
  return
113
113
  }
114
114
 
115
- this.stat.timeline.closeRead = Date.now()
115
+ this.timeline.closeRead = Date.now()
116
116
  this.sourceEnded = true
117
- log.trace('%s stream %s source end - err: %o', this.stat.direction, this.id, err)
117
+ log.trace('%s stream %s source end - err: %o', this.direction, this.id, err)
118
118
 
119
119
  if (err != null && this.endErr == null) {
120
120
  this.endErr = err
121
121
  }
122
122
 
123
123
  if (this.sinkEnded) {
124
- this.stat.timeline.close = Date.now()
124
+ this.timeline.close = Date.now()
125
125
 
126
126
  if (this.onEnd != null) {
127
127
  this.onEnd(this.endErr)
@@ -134,16 +134,16 @@ export abstract class AbstractStream implements Stream {
134
134
  return
135
135
  }
136
136
 
137
- this.stat.timeline.closeWrite = Date.now()
137
+ this.timeline.closeWrite = Date.now()
138
138
  this.sinkEnded = true
139
- log.trace('%s stream %s sink end - err: %o', this.stat.direction, this.id, err)
139
+ log.trace('%s stream %s sink end - err: %o', this.direction, this.id, err)
140
140
 
141
141
  if (err != null && this.endErr == null) {
142
142
  this.endErr = err
143
143
  }
144
144
 
145
145
  if (this.sourceEnded) {
146
- this.stat.timeline.close = Date.now()
146
+ this.timeline.close = Date.now()
147
147
 
148
148
  if (this.onEnd != null) {
149
149
  this.onEnd(this.endErr)
@@ -153,7 +153,7 @@ export abstract class AbstractStream implements Stream {
153
153
 
154
154
  // Close for both Reading and Writing
155
155
  close (): void {
156
- log.trace('%s stream %s close', this.stat.direction, this.id)
156
+ log.trace('%s stream %s close', this.direction, this.id)
157
157
 
158
158
  this.closeRead()
159
159
  this.closeWrite()
@@ -161,7 +161,7 @@ export abstract class AbstractStream implements Stream {
161
161
 
162
162
  // Close for reading
163
163
  closeRead (): void {
164
- log.trace('%s stream %s closeRead', this.stat.direction, this.id)
164
+ log.trace('%s stream %s closeRead', this.direction, this.id)
165
165
 
166
166
  if (this.sourceEnded) {
167
167
  return
@@ -172,7 +172,7 @@ export abstract class AbstractStream implements Stream {
172
172
 
173
173
  // Close for writing
174
174
  closeWrite (): void {
175
- log.trace('%s stream %s closeWrite', this.stat.direction, this.id)
175
+ log.trace('%s stream %s closeWrite', this.direction, this.id)
176
176
 
177
177
  if (this.sinkEnded) {
178
178
  return
@@ -191,7 +191,7 @@ export abstract class AbstractStream implements Stream {
191
191
  })
192
192
  }
193
193
  } catch (err) {
194
- log.trace('%s stream %s error sending close', this.stat.direction, this.id, err)
194
+ log.trace('%s stream %s error sending close', this.direction, this.id, err)
195
195
  }
196
196
 
197
197
  this.onSinkEnd()
@@ -199,7 +199,7 @@ export abstract class AbstractStream implements Stream {
199
199
 
200
200
  // Close for reading and writing (local error)
201
201
  abort (err: Error): void {
202
- log.trace('%s stream %s abort', this.stat.direction, this.id, err)
202
+ log.trace('%s stream %s abort', this.direction, this.id, err)
203
203
  // End the source with the passed error
204
204
  this.streamSource.end(err)
205
205
  this.abortController.abort()
@@ -234,7 +234,7 @@ export abstract class AbstractStream implements Stream {
234
234
  try {
235
235
  source = abortableSource(source, signal)
236
236
 
237
- if (this.stat.direction === 'outbound') { // If initiator, open a new stream
237
+ if (this.direction === 'outbound') { // If initiator, open a new stream
238
238
  const res = this.sendNewStream()
239
239
 
240
240
  if (isPromise(res)) {
@@ -282,9 +282,9 @@ export abstract class AbstractStream implements Stream {
282
282
 
283
283
  // Send no more data if this stream was remotely reset
284
284
  if (err.code === ERR_STREAM_RESET) {
285
- log.trace('%s stream %s reset', this.stat.direction, this.id)
285
+ log.trace('%s stream %s reset', this.direction, this.id)
286
286
  } else {
287
- log.trace('%s stream %s error', this.stat.direction, this.id, err)
287
+ log.trace('%s stream %s error', this.direction, this.id, err)
288
288
  try {
289
289
  const res = this.sendReset()
290
290
 
@@ -292,9 +292,9 @@ export abstract class AbstractStream implements Stream {
292
292
  await res
293
293
  }
294
294
 
295
- this.stat.timeline.reset = Date.now()
295
+ this.timeline.reset = Date.now()
296
296
  } catch (err) {
297
- log.trace('%s stream %s error sending reset', this.stat.direction, this.id, err)
297
+ log.trace('%s stream %s error sending reset', this.direction, this.id, err)
298
298
  }
299
299
  }
300
300
 
@@ -313,7 +313,7 @@ export abstract class AbstractStream implements Stream {
313
313
  await res
314
314
  }
315
315
  } catch (err) {
316
- log.trace('%s stream %s error sending close', this.stat.direction, this.id, err)
316
+ log.trace('%s stream %s error sending close', this.direction, this.id, err)
317
317
  }
318
318
 
319
319
  this.onSinkEnd()