Skip to main content
Module

x/smoldot2/client.d.ts>ClientOptions

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

Configuration of a client.

Properties

optional
logCallback: LogCallback

Callback that the client will invoke in order to report a log event.

By default, prints the log on the console. If you want to disable logging altogether, please pass an empty callback function.

optional
maxLogLevel: number

The client will never call the log callback with a value of level superior to this value. Defaults to 3.

While this filtering could be done manually in the logCallback, passing a maximum log level leads to better performances as the client doesn't even need to generate a message when it knows that this message isn't interesting.

optional
cpuRateLimit: number

Maximum amount of CPU that the client should consume on average.

This must be a number between 0.0 and 1.0. For example, passing 0.25 bounds the client to 25% of CPU power. Defaults to 1.0 if no value is provided.

Note that this is implemented by sleeping for certain amounts of time in order for the average CPU consumption to not go beyond the given limit. It is therefore still possible for the client to use high amounts of CPU for short amounts of time.

optional
forbidTcp: boolean

If true, then the client will never open any TCP connection. Defaults to false.

This option can be used in order to mimic an environment where the TCP protocol isn't supported (e.g. browsers) from an environment where TCP is supported (e.g. NodeJS).

This option has no effect in environments where the TCP protocol isn't supported anyway.

optional
forbidWs: boolean

If true, then the client will never open any non-secure WebSocket connection. Defaults to false.

This option can be used in order to mimic an environment where non-secure WebSocket connections aren't supported (e.g. web pages) from an environment where they are supported (e.g. NodeJS).

This option has no effect in environments where non-secure WebSocket connections aren't supported anyway.

optional
forbidNonLocalWs: boolean

If true, then the client will never open any non-secure WebSocket connection to addresses other than localhost or 127.0.0.1. Defaults to false.

This option is similar to forbidWs, except that connections to localhost and 127.0.0.1 do not take the value of this option into account.

This option can be used in order to mimic an environment where non-secure WebSocket connections aren't supported (e.g. web pages) from an environment where they are supported (e.g. NodeJS).

This option has no effect in environments where non-secure WebSocket connections aren't supported anyway.

optional
forbidWss: boolean

If true, then the client will never open any secure WebSocket connection. Defaults to false.

This option exists of the sake of completeness. All environments support secure WebSocket connections.

optional
forbidWebRtc: boolean

If true, then the client will never open any WebRTC connection. Defaults to false.

This option has no effect in environments where non-secure WebSocket connections aren't supported anyway.