Skip to main content
Module

x/smoldot2/instance/bindings-smoldot-light.d.ts>ConnectionConfig

Alternative client for Substrate-based chains.
Go to Latest
interface ConnectionConfig
import { type ConnectionConfig } from "https://deno.land/x/smoldot2@light-js-deno-v1.0.1/instance/bindings-smoldot-light.d.ts";

Configuration for a connection.

Properties

address: string

Multiaddress in string format that describes which node to try to connect to.

Note that this address shouldn't be trusted. The value in this field might have been chosen by a potentially malicious peer.

onOpen: (info: { type: "single-stream"; handshake: "multistream-select-noise-yamux"; initialWritableBytes: number; writeClosable: boolean; } | { type: "multi-stream"; handshake: "webrtc"; localTlsCertificateMultihash: Uint8Array; remoteTlsCertificateMultihash: Uint8Array; }) => void

Callback called when the connection transitions from the Opening to 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",
initialWritableBytes: number,
) => 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) => 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 more data can be written on the stream.

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

This callback must not be called after closeSend has been called.

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".