Networking · class
InputLog
Explained in Networking and rollback.
class InputLogimport { InputLog } from '@driftengine/network';Constructor
new
constructor(options: InputLogOptions)| Parameter | Type | Description |
|---|---|---|
options | InputLogOptions |
Properties
| Name | Type | Description |
|---|---|---|
participantsreadonly | number | |
depthreadonly | number | |
inputBytesreadonly | number |
Accessors
| Name | Type | Description |
|---|---|---|
windowStartget | number | The oldest tick this log holds. Everything below it has been dropped. |
windowEndget | number | One past the newest tick this log will accept. |
Methods
holds
holds(tick: number): booleanWhether a tick is inside the window at all.
| Parameter | Type | Description |
|---|---|---|
tick | number |
retain
retain(oldest: number): voidMove the window so oldest is the earliest tick kept, forgetting what falls off.
| Parameter | Type | Description |
|---|---|---|
oldest | number |
More
The slots that leave are cleared rather than left, because their slotTick would otherwise
match a tick a whole window later and answer a stale input as a confirmed one.
set
set(participant: number, tick: number, payload: Uint8Array): booleanRecord a real input. true when this changed what the slot held, which is what tells a
rewind whether it has anything to do. false also means refused, for a tick outside the
window — see holds to tell the two apart when it matters.
| Parameter | Type | Description |
|---|---|---|
participant | number | |
tick | number | |
payload | Uint8Array |
More
A confirmed input matching the guess is the common case on a held control, and replaying for it would burn a rewind to produce the identical world.
into
into(participant: number, tick: number, out: Uint8Array): booleanThe input to simulate with, guessing and storing one if none has arrived.
| Parameter | Type | Description |
|---|---|---|
participant | number | |
tick | number | |
out | Uint8Array |
More
false means it was guessed, or that the tick is outside the window, in which case out is
zeroed. A caller deciding whether a tick can be confirmed reads that; a caller simulating does
not care, because either way out holds the bytes this tick ran with, now and on every replay.
isConfirmed
isConfirmed(participant: number, tick: number): booleanWhether a real input for this participant and tick has arrived.
| Parameter | Type | Description |
|---|---|---|
participant | number | |
tick | number |
isComplete
isComplete(tick: number): booleanWhether every participant's input for this tick has arrived. What lockstep advances on.
| Parameter | Type | Description |
|---|---|---|
tick | number |
confirmedThrough
confirmedThrough(upTo: number): numberThe highest tick at or below upTo such that every tick from the window's start up to it is
complete, or -1.
| Parameter | Type | Description |
|---|---|---|
upTo | number |
More
Walked upward from the start of the window and stopped at the first gap, which is the property that matters: ticks 40 and 42 confirmed with 41 missing is not a session confirmed to 42, and answering 42 would let a peer discard the snapshot it still needs to correct 41.