watchEpochNumber
Watches and returns incoming epoch numbers.
Usage
import { } from "./client";
const = .({
: () => {
.();
},
});
> 102224432n> 102224435n> 102224438nimport { , } from "cive";
import { } from "cive/chains";
export const = ({
: ,
: (),
});Listener
(blockNumber: bigint) => void
The block number.
Returns
UnwatchFn
A function that can be invoked to stop watching for new block numbers.
Parameters
epochTag (optional)
- Type
latest_mined|latest_state|latest_confirmed|latest_checkpoint|earliest - Defaut
latest_mined
const = .({
: 'latest_mined',
: () => {
.();
},
});emitMissed (optional)
- Type:
boolean - Default:
false
Whether or not to emit missed block numbers to the callback.
Missed block numbers may occur in instances where internet connection is lost, or the block time is lesser than the polling interval of the client.
const = .({
: true,
: () => {
.();
},
});emitOnBegin (optional)
- Type:
boolean - Default:
false
Whether or not to emit the latest block number to the callback when the subscription opens.
const = .({
: true,
: true,
: () => {
.();
},
});poll (optional)
- Type:
boolean - Default:
falsefor WebSocket Transports,truefor non-WebSocket Transports
Whether or not to use a polling mechanism to check for new block numbers instead of a WebSocket subscription.
This option is only configurable for Clients with a WebSocket Transport.
TODO
pollingInterval (optional)
- Type:
number
Polling frequency (in ms). Defaults to Client's pollingInterval config.
const = .({
: true,
: true,
: 12_000,
: () => {
.();
},
});