silverback.state
The silverback.state
module contains modules for loading an unloading the shared memory for a
Silverback bot, which can be loaded from a persistent store and snapshotted at regular intervals.
- class silverback.state.Datastore
Bases:
object
Very basic implementation used to store bot state and handler result data by storing/retreiving state from a JSON-encoded file.
The file structure that this Recorder uses leverages the value of SILVERBACK_BOT_NAME as well as the configured network to determine the location where files get saved:
- ./.silverback-sessions/
- <bot-name>/
- <network choice>/
state.json # always write here
Note that this format can be read by basic means (even in a JS frontend):
You may also want to give your bot a unique name so the data does not get overwritten, if you are using multiple bots from the same directory:
SILVERBACK_BOT_NAME: Any alphabetical string valid as a folder name
- class silverback.state.StateSnapshot(*, last_block_seen: int, last_block_processed: int, last_nonce_used: int | None = None, last_updated: ~datetime.Annotated[~datetime.datetime, ~pydantic.functional_serializers.PlainSerializer(func=~silverback.types.iso_format, return_type=str, when_used=always)] = <factory>)
Bases:
BaseModel