diff --git a/assets/highlight.css b/assets/highlight.css index 3a2b434..8e17baf 100644 --- a/assets/highlight.css +++ b/assets/highlight.css @@ -17,14 +17,14 @@ --dark-hl-7: #9CDCFE; --light-hl-8: #A31515; --dark-hl-8: #CE9178; - --light-hl-9: #008000; - --dark-hl-9: #6A9955; - --light-hl-10: #0000FF; - --dark-hl-10: #569CD6; - --light-hl-11: #0070C1; - --dark-hl-11: #4FC1FF; - --light-hl-12: #795E26; - --dark-hl-12: #DCDCAA; + --light-hl-9: #0000FF; + --dark-hl-9: #569CD6; + --light-hl-10: #0070C1; + --dark-hl-10: #4FC1FF; + --light-hl-11: #795E26; + --dark-hl-11: #DCDCAA; + --light-hl-12: #008000; + --dark-hl-12: #6A9955; --light-hl-13: #098658; --dark-hl-13: #B5CEA8; --light-code-background: #FFFFFF; diff --git a/assets/navigation.js b/assets/navigation.js index f6ff117..6113533 100644 --- a/assets/navigation.js +++ b/assets/navigation.js @@ -1 +1 @@ -window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA43SQU+DMBQH8O/SM3ERdTHczA5mZ05m4fBsX6WRFlNeNxbDd5eBQkuZ2ZHXf368f9PDNyNsiWWM10aqD5awL6Cy/9a1cBU2m3F+V5Ku+sNPZQTL0oTxUlXComHZYSJ2C0IZQiuBz8puDXvadslkCJTgKlpSR7AK3r19glwIPqSed0Sr5HnJSWc4qdpMnB8Lte1jV3heP8M2vqVhfNMlvdYvJ+j/JHBW0Dj9Z8znIffsLXEG7dq1NiMxHP/boiGLoOMa4/ymHvkQzQkoKvKreInrVd4uu+aLdXgFTTOv42VC6D69Qu2NotV3GIuXaPwgi674AWSRsoIbAwAA" \ No newline at end of file +window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA43RTU+EMBAG4P8yZ6IRdWO4GRI/Dp7wYjYcRjq4jbRsynSFGP67ERRavrLXzpuHYd79NzDVDBFkpc7lBwRwRD5ABKoUtqDqsn+/OLAqIIBPqQVEYQDZQRbCkIZoPxDxhJCayeSYjUq8hN3u2mAwBOVoC55SJzQS3519vJwPXoeOdyIj82bK5VZnLEs9cG7M13Y3bep4Uguq51fqns860oNBRa/NkUaEtFX/xDD2sTtnhcfy/gubuBQrxDhfN7rPPBEKMot9Ocv0qa3O3lDZ+sXWZJ615A3PD26RzW9yqa8e6sabPVVsCNW8qP79rKaSLpow8uzQf4qTWD9199PJZJ2swKoa13EyPnQVrlCrl56Ly7dO2/QHybgqp/0DAAA=" \ No newline at end of file diff --git a/assets/search.js b/assets/search.js index 0a8f84e..f1aa046 100644 --- a/assets/search.js +++ b/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA8Vb227bRhD9F/pVUb03SfZb4MZFUDQt4rRBYBgGI60cIhQpkJQV1/C/d28iZ6hdmpRU5CUKpTkzh3Nmh7vL9XNU5Nsyurx9jr4n2SK6pKMoi1cyuozUpfwRjaJNkaqrVb7YpLL8xXw7/latUvXTPI3LUip4FL2Mdh4mvHbxFK82jYvlJptXSZ7tnJhfPa5G0TouZFbVHIBvIdikdn9/Xz2tZQ//Z/a/tX1HMIeyzJvATVrmebZMHvbyYr/um5hHWSTLpyvsquHvnEGr7jw5UoCvaNLUCpNklSyW8bwhfVAEck6b+0nznv7PrGVXDGceCiWz+Gsqf5dy/TZNHmXPsPuoIyh837l5r2M+xmlPEj7cETRW8Y/32dd8ky1uqkLGq7InDR/uOBp/bqrDeOwDjyCSZEmVxKn19Vn9nm9vkn/7VkgYfVxuDqTjRx5H5Q9ZlvGDHMYCg4YRYE3bXMhlvEmrVi96jItED8w6ODIb2vPqYKXJ3F6Ptl939uhZ7cNm/6aKqyZZMtusajfAoJuoYwN0aXrze1V1/dyfOdOuGBDkj3fz5cONRvQL2VgfHfWjnEvV+Rb9IwPEcdHflZWqsaT81js6RhwX/Vo1lgGhgfkBceFj/4uewlgzVGVgxDtfLcuh1Qy7jPkYFunMYTpvt30zgfClzBbXxQEcIPBAIp1z06E03Fz1DR3IZ9zcSCB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1DMzbaDhWiGsZmLfRcKwQp8Ha5FghzkI3xFuPnfAI4lghHhxBHAvEtQrM/yzDAnEjkLcdciwQN0PIW+8cK8SNQt5651ghYRTylpzACgmjkLfkBFZIaBm4t+QEVkhoHbi3kgSWSJipgbeSRGtyoIXg3koSWCOhheBejQTWSGghuFcjgTUSWgju1UhgjYQWgns1ElijiRaCezWaWI3MHFFNDiu5eG/nimq2t9t/eo7u3QSyfq30HFH1z8soUn3ffk7tpxrp5lMNEPtpfn9pppX6ShMwbx6A51njmoUwuxcmDYwBlA244+N4qAYZ9NW84wI8psAjCWDdsZl9OgTwIaHI9nCcPp0W28NxDX7SwKchtN4JLu1OMMgDCMxDtCU8ZwFIXwBVzwPYZX1QAuTqHABDQdWauagQ12a7VcEmrkxoGK7Xt0u75G6ccHDDIlQvD3msVkFzs5IFUAGgoTTb7Y+F2f4AUAKgrBO6NSvyjVuRAxcgaSJ01+4wcIMCoJBCiTl1AmQFxURCt+mO4dmdAUu5NEfPgB8Qm4RUTtzaVNq1KbhdMK4nIer1WEjqk5qNBzAgZwG8OeXaIIC+kwBiFf9I7KFMe+uotgDlizB+ZU/q7aUL9EgSKhEFz91ZTE98MB5JKGXKQ6dooFBJqMrsgh8MTNjeXTtlQbDZjangbgxQHdSeCKnm9vf2hzagIUJNdO22YvYLDtSLCMmnX/Jt3atH0ERB0tjr0Hm9XwxcAO48pJ1uaHO9F16YvXCABpUnXkVv7YY+gINb5yH+Gt5uawyMGB5qFaYNF+2SAW2YctfLQ5ppD5ncuuMqMD54IvDQkNXowr5LAUhQaDxUaBoZloyC4ca6gmMX+52dgUbJurIYfDSANIggk6qFokA8euFGbajx7OeegKAk9CB1TaodmoDQJEj4KSvqs6UAC2qdBIv1KSv1NcSBIichxe2fcuzPz2CdBaD6tdAyL7prhoGaEaFnovtzHEAdMO/C7ItEQZmzUGMA2PZcgILQ1NvR1QJgnaxlmmTK6Pbu5eU/tVXK6qs0AAA="; \ No newline at end of file +window.searchData = "data:application/octet-stream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GyWaYozayHzDy+/SkgiA86iKTmr0UX7k0hQILqlFR1WiQtGQdzVgwFxy4OVx8BmrkYyiK5fIE0KJJJ1UNxIB5v9nCCaqaHuWcgKCNZ1zC86VZAek2tFk2L7HNmgDMjZXvOivYPDgEWTBJG7U7K56ys/0wS4MDsYNTkOti9gZagqaS6fxTgcG8Oq5qGlr2Gq0AZaapl20ecm7wYrmwBKltSmaKKUYF0aaqZNP+aBEgyyPEQZmuv0Pq7Kg1GHlEjr+GHZcxBI+CUugDbj80Bc+5tYLdhsEt2Jk0yE1wtb19f/weKZR+AqUMAAA=="; \ No newline at end of file diff --git a/assets/style.css b/assets/style.css index 108428c..07a385b 100644 --- a/assets/style.css +++ b/assets/style.css @@ -11,6 +11,7 @@ --light-color-text-aside: #6e6e6e; --light-color-link: #1f70c2; + --light-color-ts-keyword: #056bd6; --light-color-ts-project: #b111c9; --light-color-ts-module: var(--light-color-ts-project); --light-color-ts-namespace: var(--light-color-ts-project); @@ -50,6 +51,7 @@ --dark-color-text-aside: #dddddd; --dark-color-link: #00aff4; + --dark-color-ts-keyword: #3399ff; --dark-color-ts-project: #e358ff; --dark-color-ts-module: var(--dark-color-ts-project); --dark-color-ts-namespace: var(--dark-color-ts-project); @@ -91,6 +93,7 @@ --color-text-aside: var(--light-color-text-aside); --color-link: var(--light-color-link); + --color-ts-keyword: var(--light-color-ts-keyword); --color-ts-module: var(--light-color-ts-module); --color-ts-namespace: var(--light-color-ts-namespace); --color-ts-enum: var(--light-color-ts-enum); @@ -132,6 +135,7 @@ --color-text-aside: var(--dark-color-text-aside); --color-link: var(--dark-color-link); + --color-ts-keyword: var(--dark-color-ts-keyword); --color-ts-module: var(--dark-color-ts-module); --color-ts-namespace: var(--dark-color-ts-namespace); --color-ts-enum: var(--dark-color-ts-enum); @@ -180,6 +184,7 @@ body { --color-text-aside: var(--light-color-text-aside); --color-link: var(--light-color-link); + --color-ts-keyword: var(--light-color-ts-keyword); --color-ts-module: var(--light-color-ts-module); --color-ts-namespace: var(--light-color-ts-namespace); --color-ts-enum: var(--light-color-ts-enum); @@ -219,6 +224,7 @@ body { --color-text-aside: var(--dark-color-text-aside); --color-link: var(--dark-color-link); + --color-ts-keyword: var(--dark-color-ts-keyword); --color-ts-module: var(--dark-color-ts-module); --color-ts-namespace: var(--dark-color-ts-namespace); --color-ts-enum: var(--dark-color-ts-enum); @@ -984,6 +990,11 @@ a.tsd-index-link { overflow-x: auto; } +.tsd-signature-keyword { + color: var(--color-ts-keyword); + font-weight: normal; +} + .tsd-signature-symbol { color: var(--color-text-aside); font-weight: normal; diff --git a/classes/stream.YamuxStream.html b/classes/stream.YamuxStream.html index bd1a05f..8796e1b 100644 --- a/classes/stream.YamuxStream.html +++ b/classes/stream.YamuxStream.html @@ -1,50 +1,90 @@ -
YamuxStream is used to represent a logical stream within a session
+Private
Readonly
_idPrivate
Readonly
configPrivate
epochAn 'epoch' is the time it takes to process and read data
+Private
Readonly
_idPrivate
Readonly
configPrivate
epochAn 'epoch' is the time it takes to process and read data
Used in conjunction with RTT to determine whether to increase the recvWindow
-Private
Readonly
getRTTOptional
namePrivate
recvThe number of bytes available to receive in a full window
-Private
recvThe number of available bytes to receive
-Private
Readonly
sendOptional
body: Uint8ArrayPrivate
sendThe number of available bytes to send
-Private
Optional
sendCallback to notify that the sendWindowCapacity has been updated
-Private
getPrivate
Readonly
getRTTProtected
Readonly
logOptional
nameOptional
protocolPrivate
recvThe number of bytes available to receive in a full window
+Private
recvThe number of available bytes to receive
+Private
Readonly
sendOptional
body: Uint8ArrayPrivate
sendThe number of available bytes to send
+Private
Optional
sendCallback to notify that the sendWindowCapacity has been updated
+Optional
err: ErrorOptional
err: ErrorOptional
err: ErrorClose immediately for reading and writing and send a reset message (local +error)
+Optional
options: AbortOptionsOptional
options: AbortOptionsOptional
options: AbortOptionsPrivate
gethandleData is called when the stream receives a data frame
-handleWindowUpdate is called when the stream receives a window update frame
-Private
processSend a message to the remote muxer, informing them no more data messages +
handleData is called when the stream receives a data frame
+handleWindowUpdate is called when the stream receives a window update frame
+Protected
onOptional
err: ErrorProtected
onOptional
err: ErrorPrivate
processSend a data message to the remote muxer
-Send a data message to the remote muxer
+When an extending class reads data from it's implementation-specific source, +call this method to allow the stream consumer to read the data.
+Wait for the send window to be non-zero
Will throw with ERR_STREAM_ABORT if the stream gets aborted
-Generated using TypeDoc
Used to transmit data. May transmit zero length payloads depending on the flags.
+Used to close a session.
+Used to measure RTT. It can also be used to heart-beat and do keep-alives over TCP.
+Used to updated the senders receive window size. This is used to implement per-session flow control.
+Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
-Yamux stream multiplexer for libp2p
$ npm i @chainsafe/libp2p-yamux
+Install
$ npm i @chainsafe/libp2p-yamux
-Browser <script>
tag
Loading this module through a script tag will make it's exports available as ChainsafeLibp2pYamux
in the global namespace.
+Browser <script>
tag
Loading this module through a script tag will make it's exports available as ChainsafeLibp2pYamux
in the global namespace.
<script src="https://unpkg.com/@chainsafe/libp2p-yamux/dist/index.min.js"></script>
-Usage
import { yamux } from '@chainsafe/libp2p-yamux'
import { pipe } from 'it-pipe'
import { duplexPair } from 'it-pair/duplex'
import all from 'it-all'
// Connect two yamux muxers to demo basic stream multiplexing functionality
const clientMuxer = yamux({
client: true,
onIncomingStream: stream => {
// echo data on incoming streams
pipe(stream, stream)
},
onStreamEnd: stream => {
// do nothing
}
})()
const serverMuxer = yamux({
client: false,
onIncomingStream: stream => {
// echo data on incoming streams
pipe(stream, stream)
},
onStreamEnd: stream => {
// do nothing
}
})()
// `p` is our "connections", what we use to connect the two sides
// In a real application, a connection is usually to a remote computer
const p = duplexPair()
// connect the muxers together
pipe(p[0], clientMuxer, p[0])
pipe(p[1], serverMuxer, p[1])
// now either side can open streams
const stream0 = clientMuxer.newStream()
const stream1 = serverMuxer.newStream()
// Send some data to the other side
const encoder = new TextEncoder()
const data = [encoder.encode('hello'), encoder.encode('world')]
pipe(data, stream0)
// Receive data back
const result = await pipe(stream0, all)
// close a stream
stream1.close()
// close the muxer
clientMuxer.close()
-
-API
This library implements the StreamMuxerFactory
, StreamMuxer
and Stream
interfaces defined in @libp2p/interfaces/stream-muxer
.
-Contribute
The libp2p implementation in JavaScript is a work in progress. As such, there are a few things you can do right now to help out:
-
-- Go through the modules and check out existing issues. This is especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.
-- Perform code reviews. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs.
-
-API Docs
+API Docs
-License
Licensed under either of
+License
Licensed under either of
- Apache 2.0, (LICENSE-APACHE / http://www.apache.org/licenses/LICENSE-2.0)
- MIT (LICENSE-MIT / http://opensource.org/licenses/MIT)
-Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
-
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Generated using TypeDoc
Used to do periodic keep alive messages using a ping.
-Used to control the initial window size that we allow for a stream.
+Used to control the initial window size that we allow for a stream.
measured in bytes
-How often to perform the keep alive
+How often to perform the keep alive
measured in milliseconds
-Optional
logUsed to control the log destination
+Optional
logUsed to control the log destination
It can be disabled by explicitly setting to undefined
Maximum number of concurrent inbound streams that we accept. +
Maximum number of concurrent inbound streams that we accept. If the peer tries to open more streams, those will be reset immediately.
-Maximum size of a message that we'll send on a stream. +
Maximum size of a message that we'll send on a stream. This ensures that a single stream doesn't hog a connection.
-Maximum number of concurrent outbound streams that we accept. +
Maximum number of concurrent outbound streams that we accept.
If the application tries to open more streams, the call to newStream
will throw
Used to control the maximum window size that we allow for a stream.
-Used to control the maximum window size that we allow for a stream.
+Generated using TypeDoc
The flags field is used to provide additional information related to the message type.
+The meaning of the length field depends on the message type:
+The StreamID field is used to identify the logical stream the frame is addressing. +The client side should use odd ID's, and the server even. +This prevents any collisions. Additionally, the 0 ID is reserved to represent the session.
+The type field is used to switch the frame message type.
+Optional
versionThe version field is used for future backward compatibility. +At the current time, the field is always set to 0, to indicate the initial version.
+Generated using TypeDoc
Optional
directionOutbound stream muxers are opened by the local node, inbound stream muxers are opened by the remote
+Optional
enableUsed to do periodic keep alive messages using a ping.
+Optional
initialUsed to control the initial window size that we allow for a stream.
+measured in bytes
+Optional
keepHow often to perform the keep alive
+measured in milliseconds
+Optional
logUsed to control the log destination
+It can be disabled by explicitly setting to undefined
Optional
maxMaximum number of concurrent inbound streams that we accept. +If the peer tries to open more streams, those will be reset immediately.
+Optional
maxMaximum size of a message that we'll send on a stream. +This ensures that a single stream doesn't hog a connection.
+Optional
maxMaximum number of concurrent outbound streams that we accept.
+If the application tries to open more streams, the call to newStream
will throw
Optional
maxUsed to control the maximum window size that we allow for a stream.
+Optional
onA callback function invoked every time an incoming stream is opened
+Optional
onA callback function invoke every time a stream ends
+Generated using TypeDoc
Optional
nameOptional
body: Uint8ArrayOptional
closeHow long to wait in ms for stream data to be written to the underlying +connection when closing the writable end of the stream. (default: 500)
+The stream direction
+A unique identifier for this stream
+A Logger implementation used to log stream-specific information
+Optional
metadataUser specific stream metadata
+Optional
nameOptional
sendAfter the stream sink has closed, a limit on how long it takes to send +a close-write message to the remote peer.
+Optional
onInvoked when the the stream has errored
+Optional
onOptional
onOptional
onInvoked when the stream ends
+Optional
err: ErrorOptional
onOptional
body: Uint8ArrayGenerated using TypeDoc
Generated using TypeDoc
This module is a JavaScript implementation of Yamux from Hashicorp designed to be used with js-libp2p.
+import { createLibp2p } from 'libp2p'
import { yamux } from '@chainsafe/libp2p-yamux'
const node = await createLibp2p({
// ... other options
streamMuxers: [
yamux()
]
})
+
+import { yamux } from '@chainsafe/libp2p-yamux'
import { pipe } from 'it-pipe'
import { duplexPair } from 'it-pair/duplex'
import all from 'it-all'
// Connect two yamux muxers to demo basic stream multiplexing functionality
const clientMuxer = yamux({
client: true,
onIncomingStream: stream => {
// echo data on incoming streams
pipe(stream, stream)
},
onStreamEnd: stream => {
// do nothing
}
})()
const serverMuxer = yamux({
client: false,
onIncomingStream: stream => {
// echo data on incoming streams
pipe(stream, stream)
},
onStreamEnd: stream => {
// do nothing
}
})()
// `p` is our "connections", what we use to connect the two sides
// In a real application, a connection is usually to a remote computer
const p = duplexPair()
// connect the muxers together
pipe(p[0], clientMuxer, p[0])
pipe(p[1], serverMuxer, p[1])
// now either side can open streams
const stream0 = clientMuxer.newStream()
const stream1 = serverMuxer.newStream()
// Send some data to the other side
const encoder = new TextEncoder()
const data = [encoder.encode('hello'), encoder.encode('world')]
pipe(data, stream0)
// Receive data back
const result = await pipe(stream0, all)
// close a stream
stream1.close()
// close the muxer
clientMuxer.close()
+
+Generated using TypeDoc
Generated using TypeDoc
Const
Const
Generated using TypeDoc
YamuxStream is used to represent a logical stream within a session
-