Packages
network
classes
Syncworker

@latticexyz/network / SyncWorker

Class: SyncWorker

Type parameters

NameType
Cextends Components

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new SyncWorker<C>()

Type parameters

NameType
Cextends Components

Defined in

workers/SyncWorker.ts:74 (opens in a new tab)

Properties

input$

Private input$: Subject<Input>

Defined in

workers/SyncWorker.ts:70 (opens in a new tab)


output$

Private output$: Subject<NetworkEvent

Defined in

workers/SyncWorker.ts:71 (opens in a new tab)


syncState

Private syncState: SyncStateStruct

Defined in

workers/SyncWorker.ts:72 (opens in a new tab)

Methods

init

Private init(): Promise<void>

Start the sync process.

  1. Get config
  2. Load initial state 2.1 Get cache block number 2.2 Get snapshot block number 2.3 Load from more recent source
  3. Cach up to current block number by requesting events from RPC ( -> TODO: Replace with own service)
  4. Keep in sync 4.1 If available keep in sync with streaming service 4.2 Else keep in sync with RPC

Returns

Promise<void>

Defined in

workers/SyncWorker.ts:121 (opens in a new tab)


setLoadingState

Private setLoadingState(loadingState, blockNumber?): void

Pass a loading state component update to the main thread. Can be used to indicate the initial loading state on a loading screen.

Parameters

NameTypeDefault valueDescription
loadingStatePartial<{ msg: string ; percentage: number ; state: SyncState }>undefined{ state: SyncState, msg: Message to describe the current loading step. percentage: Number between 0 and 100 to describe the loading progress. }
blockNumbernumber0Optional: block number to pass in the component update.

Returns

void

Defined in

workers/SyncWorker.ts:89 (opens in a new tab)


work

work(input$): Observable<NetworkEvent

Parameters

NameType
input$Observable<Input>

Returns

Observable<NetworkEvent

Implementation of

DoWork.work

Defined in

workers/SyncWorker.ts:321 (opens in a new tab)