Synchronizer
The Synchronizer helps you synchronize on-chain data to the local environment.
Data Structure
SynchronizerStatus
Property | Type | Description |
---|---|---|
chains | ChainStatus[] | The list of ChainStatus |
ChainStatus
Property | Type | Description |
---|---|---|
chainId | bigint | Chain id |
syncedBlock | bigint | Synced block number |
targetBlock | bigint | Target block number |
contracts | ContractStatus[] | The list of ContractStatus |
ContractStatus
Property | Type | Description |
---|---|---|
contractAddress | string | Contract address |
syncedBlock | bigint | 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
:
Parameter | Required | Description |
---|---|---|
disableDatapackerFetcher | false | Disable the datapacker fetcher. |
enableDatapackerFetcherValidate | false | Enable the datapacker fetcher validate. |
disableSequencerFetcher | false | Disable the sequencer fetcher. |
enableSequencerFetcherValidate | false | Enable the sequencer fetcher validate. |
disableProviderFetcher | false | Disable the provider fetcher. |
disableProviderFetcherValidate | false | Disable the provider fetcher validate. |
disableRuleValidator | false | Disable the rule validator. |
disableRuleValidatorIntegrityCheck | false | Disable the rule validator integrity check. |
disableRuleValidatorSequenceCheck | false | Disable the rule validator sequence check. |
disableRuleValidatorCounterCheck | false | Disable the rule validator counter check. |
disableRuleValidatorTreeCheck | false | Disable the rule validator tree check. |
fetcherFetchTimeoutMs | false | The fetcher fetch timeout in milliseconds. |
fetcherQueryLoadedBlockTimeoutMs | false | The fetcher query loaded block timeout in milliseconds. |
validatorValidateConcurrency | false | The validator validate concurrency, enforced to 1 in the SDK. |
chainIds | false | 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
:
Parameter | Required | Description |
---|---|---|
chains | false | The list of ResetChainOptions. |
ResetChainOptions
:
Parameter | Required | Description |
---|---|---|
chainId | true | The chain id. |
contract_addresses | false | The contract addresses. |
block_number | false | The block number. |