Skip to main content

Synchronizer

The Synchronizer helps you synchronize on-chain data to the local environment.

Data Structure

SynchronizerStatus

PropertyTypeDescription
chainsChainStatus[]
The list of ChainStatus

ChainStatus

PropertyTypeDescription
chainIdbigint
Chain id
syncedBlockbigint
Synced block number
targetBlockbigint
Target block number
contractsContractStatus[]
The list of ContractStatus

ContractStatus

PropertyTypeDescription
contractAddressstring
Contract address
syncedBlockbigint
Synced block number

ChainSyncedBlock

Sync block data according to chain id.

import mystiko from '@mystikonetwork/node';

const blockNumber = mystiko.synchronizer?.chainSyncedBlock(BigInt(97));

ContractSyncedBlock

Sync block data according to chain id and contract address.

import mystiko from '@mystikonetwork/node';

const blockNumber = mystiko.synchronizer?.contractSyncedBlock(
BigInt(11155111),
'0xAE77941b3bd4d2293E13A9a69E64A0ACFf5bBC55',
);

Status

Check the Sync Status.

Parameter: withContracts Indicates whether to include contract-related data in the synchronization status.

import mystiko from '@mystikonetwork/node';

const synchronizerStatus = mystiko.synchronizer?.status(false);

Sync

Synchronize the transaction data for the Mystiko contract. The SynchronizerSyncOptions validatorValidateConcurrency level is enforced to 1 in the SDK.

import mystiko from '@mystikonetwork/node';
import { core } from '@mystikonetwork/protos';

const options = new core.synchronizer.v1.SynchronizerSyncOptions({
chainIds: [BigInt(1)],
});
const synchronizerStatus = mystiko.synchronizer?.sync(options);

The parameter list for SynchronizerSyncOptions:

ParameterRequiredDescription
disableDatapackerFetcherfalse
Disable the datapacker fetcher.
enableDatapackerFetcherValidatefalse
Enable the datapacker fetcher validate.
disableSequencerFetcherfalse
Disable the sequencer fetcher.
enableSequencerFetcherValidatefalse
Enable the sequencer fetcher validate.
disableProviderFetcherfalse
Disable the provider fetcher.
disableProviderFetcherValidatefalse
Disable the provider fetcher validate.
disableRuleValidatorfalse
Disable the rule validator.
disableRuleValidatorIntegrityCheckfalse
Disable the rule validator integrity check.
disableRuleValidatorSequenceCheckfalse
Disable the rule validator sequence check.
disableRuleValidatorCounterCheckfalse
Disable the rule validator counter check.
disableRuleValidatorTreeCheckfalse
Disable the rule validator tree check.
fetcherFetchTimeoutMsfalse
The fetcher fetch timeout in milliseconds.
fetcherQueryLoadedBlockTimeoutMsfalse
The fetcher query loaded block timeout in milliseconds.
validatorValidateConcurrencyfalse
The validator validate concurrency, enforced to 1 in the SDK.
chainIdsfalse
The list of chain ids.

Reset

Reset the synchronization data.

import mystiko from '@mystikonetwork/node';
import { core } from '@mystikonetwork/protos';

const options = new core.synchronizer.v1.SynchronizerResetOptions({
chains: [
new core.synchronizer.v1.ResetChainOptions({
chainId: BigInt(11155111),
}),
],
});
const synchronizerStatus = mystiko.synchronizer?.reset(options);

The parameter list for SynchronizerResetOptions:

ParameterRequiredDescription
chainsfalse
The list of ResetChainOptions.

ResetChainOptions:

ParameterRequiredDescription
chainIdtrue
The chain id.
contract_addressesfalse
The contract addresses.
block_numberfalse
The block number.