@latticexyz/network / SyncWorker
Class: SyncWorker
Type parameters
Name | Type |
---|---|
C | extends Components |
Implements
DoWork
<Input
,NetworkEvent
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new SyncWorker<C
>()
Type parameters
Name | Type |
---|---|
C | extends 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.
- Get config
- Load initial state 2.1 Get cache block number 2.2 Get snapshot block number 2.3 Load from more recent source
- Cach up to current block number by requesting events from RPC ( -> TODO: Replace with own service)
- 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
Name | Type | Default value | Description |
---|---|---|---|
loadingState | Partial <{ 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. } |
blockNumber | number | 0 | Optional: 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
Name | Type |
---|---|
input$ | Observable <Input > |
Returns
Observable
<NetworkEvent
Implementation of
DoWork.work