Packages
services
Snapshot

snapshot

import "command-line-arguments"

Index

Constants

SerializedStateFilename is the name for the snapshot binary of ECS State.

const SerializedStateFilename string = "./snapshots/SerializedECSState"

SerializedWorldsFilename is the name for the snapshot binary of Worlds.

const SerializedWorldsFilename string = "./snapshots/SerializedWorlds"

SnapshotDir is the directory name for where the ECS snapshots are stored.

const SnapshotDir string = "snapshots"

func ChunkRawStateSnapshot (opens in a new tab)

func ChunkRawStateSnapshot(rawStateSnapshot *pb.ECSStateSnapshot, chunkPercentage int) []*pb.ECSStateSnapshot

ChunkRawStateSnapshot splits a rawStateSnapshot ECSStateSnapshot in protobuf format into a list of ECSStateSnapshot's also in protobuf format. Each ECSStateSnapshot after chunking is chunkPercentage fraction size of the original snapshot.

func IsSnaphotAvailableLatest (opens in a new tab)

func IsSnaphotAvailableLatest(worldAddress string) bool

func IsWorldAddressSnapshotAvailable (opens in a new tab)

func IsWorldAddressSnapshotAvailable() bool

IsWorldAddressSnapshotAvailable returns if a snapshot of all indexed World addresses is available.

func PruneSnapshotOwnedByComponent (opens in a new tab)

func PruneSnapshotOwnedByComponent(snapshot *pb.ECSStateSnapshot, pruneForAddress string) *pb.ECSStateSnapshot

PruneSnapshotOwnedByComponent prunes a given ECSStateSnapshot, given an address. This helps get rid of unnecessary state that a given address does not depend on in order to perform actions.

func RawReadStateSnapshotLatest (opens in a new tab)

func RawReadStateSnapshotLatest(worldAddress string) *pb.ECSStateSnapshot

RawReadStateSnapshotLatest returns the latest ECS state snapshot in protobuf format.

func RawReadWorldAddressesSnapshot (opens in a new tab)

func RawReadWorldAddressesSnapshot() *pb.Worlds

RawReadWorldAddressesSnapshot returns a snapshot of all indexed World addresses in protobuf format.

func Start (opens in a new tab)

func Start(state ChainECSState, client *ethclient.Client, startBlock *big.Int, worldAddresses []common.Address, config *SnapshotServerConfig, logger *zap.Logger)

Start starts the process of processing data from an Ethereum client, reducing the ECS state, and taking intermittent snapshots.

type ChainECSState (opens in a new tab)

ChainECSState is the full state of a chain, which is a mapping from all worlds to their ECSState.

type ChainECSState = map[string]ECSState

func Sync (opens in a new tab)

func Sync(client *ethclient.Client, fromBlock *big.Int, toBlock *big.Int, worldAddresses []common.Address, config *SnapshotServerConfig) ChainECSState

Sync performs an initial sync to the state of the chain from block number fromBlock to block number toBlock with an optional worldAddresses filter to filter the state.

If there is a snapshot available to load, uses that snapshot as the initial state and starts the sync up to the specified toBlock, otherwise starts with an empty ECS state and syncs everything while reducing the state.

Returns the entire ECS state once the sync is complete.

type ECSState (opens in a new tab)

ECSState mimics a simple state machine, hence every transformation must return the updated state and there are no objects. This type represents an ECS state on the world.

type ECSState = map[string]*sync.Map

func SnapshotToState (opens in a new tab)

func SnapshotToState(stateSnapshot *pb.ECSStateSnapshot) ECSState

type SnapshotServerConfig (opens in a new tab)

type SnapshotServerConfig struct {
    // The block number interval for how often to take regular snapshots.
    SnapshotBlockInterval int64
    // The number of blocks to fetch data for when performing an initial
    // sync. This is limited by the bandwidth limit of Geth for fetching logs, which is a hardcoded
    // constant.
    InitialSyncBlockBatchSize int64
    // The time to wait between calls to fetch batched log data when performing an initial sync.
    InitialSyncBlockBatchSyncTimeout time.Duration
    // The block number interval for how often to take intermediary
    // snapshots when performing an initial sync. This is useful in case the snapshot service
    // disconnects or fails while perfoming a lengthy initial sync.
    InitialSyncSnapshotInterval int64
 
    // Default to use when chunking snapshot to send snapshot in chunks over the wire.
    DefaultSnapshotChunkPercentage int
}

type SnapshotType (opens in a new tab)

A SnapshotType distinguishes between snapshot types if those are required.

type SnapshotType int
const (
    Latest        SnapshotType = iota // latest available snapshot
    BlockSpecific                     // snapshot at a specific block
    InitialSync                       // snapshot taken right after the service has performed a sync
)

Generated by gomarkdoc (opens in a new tab)