Skip to main content

Synchronizer

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

Data Structure

SynchronizerStatus

PropertyTypeDescription
chainsList<ChainStatus>
Chain status list

ChainStatus

PropertyTypeDescription
chainIdInt
Chain id
syncedBlockInt
Synced block number
targetBlockInt
Target block number
contractsList<ContractStatus>
Contract status list

ContractStatus

PropertyTypeDescription
contractAddressString
Contract address
syncedBlockInt
Synced block number

ChainSyncedBlock

Sync block data according to chain id.

import 'package:mystiko_flutter/mystiko_flutter.dart';

MystikoSynchronizerApi api = await Mystiko.mystikoSynchronizerApi();
Response<Int64, SynchronizerError> response = await api.chainSyncedBlock(1);

ContractSyncedBlock

Sync block data according to chain id and contract address.

import 'package:mystiko_flutter/mystiko_flutter.dart';

MystikoSynchronizerApi api = await Mystiko.mystikoSynchronizerApi();
Response<Int64, SynchronizerError> response = await api.contractSyncedBlock(1, '0x123456');

Status

Check the Sync Status.

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

import 'package:mystiko_flutter/mystiko_flutter.dart';

MystikoSynchronizerApi api = await Mystiko.mystikoSynchronizerApi();
Response<SynchronizerStatus, SynchronizerError> response = await api.status(true);

Sync

Sync the data.

import 'package:mystiko_flutter/mystiko_flutter.dart';

MystikoSynchronizerApi api = await Mystiko.mystikoSynchronizerApi();
Response<void, SynchronizerError> response = await api.sync(SynchronizerSyncOptions());

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.
chainIdsfalse
The chain ids.

Reset

Reset the synchronization data.

import 'package:mystiko_flutter/mystiko_flutter.dart';

MystikoSynchronizerApi api = await Mystiko.mystikoSynchronizerApi();
Response<void, SynchronizerError> response = await api.reset(SynchronizerResetOptions());

The parameter list for SynchronizerResetOptions:

ParameterRequiredDescription
chainsfalse
Reset chain options

ResetChainOptions:

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