Skip to main content
Module

x/smoldot2/internals/client.d.ts>ConnectionConfig

Lightweight client for Substrate-based chains, such as Polkadot and Kusama.
Go to Latest
interface ConnectionConfig
import { type ConnectionConfig } from "https://deno.land/x/smoldot2@light-js-deno-v2.0.21/internals/client.d.ts";

Configuration for a connection.

Properties

address: instance.ParsedMultiaddr

Parsed multiaddress, as returned by the parseMultiaddr function.

onMultistreamHandshakeInfo: (info: { handshake: "webrtc"; localTlsCertificateSha256: Uint8Array; }) => void

Callback called when a multistream connection knows information about its handshake. Should be called as soon as possible.

Can only happen while the connection is in the Open state.

Must only be called once per connection.

onConnectionReset: (message: string) => void

Callback called when the connection transitions to the Reset state.

It it not called if Connection.reset is manually called by the API user.

onStreamOpened: (streamId: number, direction: "inbound" | "outbound") => void

Callback called when a new substream has been opened.

This function must only be called for connections of type "multi-stream".

onStreamReset: (streamId: number, message: string) => void

Callback called when a stream transitions to the Reset state.

It it not called if Connection.resetStream is manually called by the API user.

This function must only be called for connections of type "multi-stream".

onWritableBytes: (numExtra: number, streamId?: number) => void

Callback called when some data sent using Connection.send has effectively been written on the stream, meaning that some buffer space is now free.

Can only happen while the connection is in the Open state. This callback must not be called after closeSend has been called.

The total of writable bytes must not go beyond reasonable values (e.g. a few megabytes). It is not legal to provide a dummy implementation that simply passes an exceedingly large value.

The streamId parameter must be provided if and only if the connection is of type "multi-stream".

onMessage: (message: Uint8Array, streamId?: number) => void

Callback called when a message sent by the remote has been received.

Can only happen while the connection is in the Open state.

The streamId parameter must be provided if and only if the connection is of type "multi-stream".