state

package
v1.1.38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2026 License: AGPL-3.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UniqueStateSnapshotNIDs

func UniqueStateSnapshotNIDs(nids []types.StateSnapshotNID) []types.StateSnapshotNID

Types

type PowerLevelResolver

type PowerLevelResolver interface {
	Resolve(ctx context.Context, eventID string) (*gomatrixserverlib.PowerLevelContent, error)
}

type StateResolution

type StateResolution struct {
	Querier api.QuerySenderIDAPI
	// contains filtered or unexported fields
}

func NewStateResolution

func NewStateResolution(db StateResolutionStorage, roomInfo *types.RoomInfo, querier api.QuerySenderIDAPI) StateResolution

func (*StateResolution) CalculateAndStoreStateAfterEvents

func (v *StateResolution) CalculateAndStoreStateAfterEvents(
	ctx context.Context,
	prevStates []types.StateAtEvent,
) (types.StateSnapshotNID, error)

CalculateAndStoreStateAfterEvents finds the room state after the given events. Stores the resulting state in the database and returns a numeric ID for that snapshot.

func (*StateResolution) CalculateAndStoreStateBeforeEvent

func (v *StateResolution) CalculateAndStoreStateBeforeEvent(
	ctx context.Context,
	event gomatrixserverlib.PDU,
	isRejected bool,
) (types.StateSnapshotNID, error)

CalculateAndStoreStateBeforeEvent calculates a snapshot of the state of a room before an event. Stores the snapshot of the state in the database. Returns a numeric ID for the snapshot of the state before the event.

func (*StateResolution) DifferenceBetweeenStateSnapshots

func (v *StateResolution) DifferenceBetweeenStateSnapshots(
	ctx context.Context, oldStateNID, newStateNID types.StateSnapshotNID,
) (removed, added []types.StateEntry, err error)

DifferenceBetweeenStateSnapshots works out which state entries have been added and removed between two snapshots.

func (*StateResolution) LoadCombinedStateAfterEvents

func (v *StateResolution) LoadCombinedStateAfterEvents(
	ctx context.Context, prevStates []types.StateAtEvent,
) ([]types.StateEntry, error)

LoadCombinedStateAfterEvents loads a snapshot of the state after each of the events and combines those snapshots together into a single list. At this point it is possible to run into duplicate (type, state key) tuples.

func (*StateResolution) LoadMembershipAtEvent

func (v *StateResolution) LoadMembershipAtEvent(
	ctx context.Context, eventIDs []string, stateKeyNID types.EventStateKeyNID,
) (map[string][]types.StateEntry, error)

func (*StateResolution) LoadStateAfterEventsForStringTuples

func (v *StateResolution) LoadStateAfterEventsForStringTuples(
	ctx context.Context,
	prevStates []types.StateAtEvent,
	stateKeyTuples []gomatrixserverlib.StateKeyTuple,
) ([]types.StateEntry, error)

LoadStateAfterEventsForStringTuples loads the state for a list of event type and state key pairs after list of events. This is used when we only want to load a subset of the room state after a list of events. If there is no entry for a given event type and state key pair then it will be discarded. This is typically the state before an event. Returns a sorted list of state entries or an error if there was a problem talking to the database.

func (*StateResolution) LoadStateAtEvent

func (v *StateResolution) LoadStateAtEvent(
	ctx context.Context, eventID string,
) ([]types.StateEntry, error)

LoadStateAtEvent loads the full state of a room before a particular event.

func (*StateResolution) LoadStateAtEventForHistoryVisibility

func (v *StateResolution) LoadStateAtEventForHistoryVisibility(
	ctx context.Context, eventID string,
) ([]types.StateEntry, error)

LoadStateAtEvent loads the full state of a room before a particular event.

func (*StateResolution) LoadStateAtSnapshot

func (v *StateResolution) LoadStateAtSnapshot(
	ctx context.Context, stateNID types.StateSnapshotNID,
) ([]types.StateEntry, error)

LoadStateAtSnapshot loads the full state of a room at a particular snapshot. This is typically the state before an event or the current state of a room. Returns a sorted list of state entries or an error if there was a problem talking to the database.

func (*StateResolution) LoadStateAtSnapshotForStringTuples

func (v *StateResolution) LoadStateAtSnapshotForStringTuples(
	ctx context.Context,
	stateNID types.StateSnapshotNID,
	stateKeyTuples []gomatrixserverlib.StateKeyTuple,
) ([]types.StateEntry, error)

LoadStateAtSnapshotForStringTuples loads the state for a list of event type and state key pairs at a snapshot. This is used when we only want to load a subset of the room state at a snapshot. If there is no entry for a given event type and state key pair then it will be discarded. This is typically the state before an event or the current state of a room. Returns a sorted list of state entries or an error if there was a problem talking to the database.

func (*StateResolution) Resolve

type StateResolutionStorage

type StateResolutionStorage interface {
	EventTypeNIDs(ctx context.Context, eventTypes []string) (map[string]types.EventTypeNID, error)
	EventStateKeyNIDs(ctx context.Context, eventStateKeys []string) (map[string]types.EventStateKeyNID, error)
	StateBlockNIDs(ctx context.Context, stateNIDs []types.StateSnapshotNID) ([]types.StateBlockNIDList, error)
	StateEntries(ctx context.Context, stateBlockNIDs []types.StateBlockNID) ([]types.StateEntryList, error)
	SnapshotNIDFromEventID(ctx context.Context, eventID string) (types.StateSnapshotNID, error)
	BulkSelectSnapshotsFromEventIDs(ctx context.Context, eventIDs []string) (map[types.StateSnapshotNID][]string, error)
	StateEntriesForTuples(ctx context.Context, stateBlockNIDs []types.StateBlockNID, stateKeyTuples []types.StateKeyTuple) ([]types.StateEntryList, error)
	StateAtEventIDs(ctx context.Context, eventIDs []string) ([]types.StateAtEvent, error)
	AddState(ctx context.Context, roomNID types.RoomNID, stateBlockNIDs []types.StateBlockNID, state []types.StateEntry) (types.StateSnapshotNID, error)
	Events(ctx context.Context, roomVersion gomatrixserverlib.RoomVersion, eventNIDs []types.EventNID) ([]types.Event, error)
	EventsFromIDs(ctx context.Context, roomInfo *types.RoomInfo, eventIDs []string) ([]types.Event, error)
	IsEventRejected(ctx context.Context, roomNID types.RoomNID, eventID string) (bool, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL