state

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveConflictsAdhoc

func ResolveConflictsAdhoc(
	version gomatrixserverlib.RoomVersion,
	events []*gomatrixserverlib.Event,
	authEvents []*gomatrixserverlib.Event,
) ([]*gomatrixserverlib.Event, error)

ResolveConflictsAdhoc is a helper function to assist the query API in performing state resolution when requested. This is a different code path to the rest of state.go because this assumes you already have gomatrixserverlib.Event objects and not just a bunch of NIDs like elsewhere in the state resolution. TODO: Some of this can possibly be deduplicated

Types

type StateResolution

type StateResolution struct {
	// contains filtered or unexported fields
}

func NewStateResolution

func NewStateResolution(db storage.Database, roomInfo types.RoomInfo) 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.Event,
	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) 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) 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.

Jump to

Keyboard shortcuts

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