block

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: AGPL-3.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DEL_PROP_KEY = "DEL"
	MOV_PROP_KEY = "MOV"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	BlockID       common.BlockID
	Version       Version
	Props         Props
	Text          *text.Text
	ParentBlockID *common.BlockID
	Point         point.Point
	IsDeleted     bool
}

func (*Block) Apply

func (block *Block) Apply(ctrb Contribution) error

func (Block) MarshalJSON

func (block Block) MarshalJSON() ([]byte, error)

func (*Block) UnmarshalJSON

func (block *Block) UnmarshalJSON(data []byte) error

type BlockPoint

type BlockPoint struct {
	ParentBlockID common.BlockID
	Point         point.Point
}

func (BlockPoint) MarshalJSON

func (bp BlockPoint) MarshalJSON() ([]byte, error)

func (*BlockPoint) UnmarshalJSON

func (bp *BlockPoint) UnmarshalJSON(data []byte) error

type Contribution

type Contribution struct {
	BlockID    common.BlockID `json:"blockID"`
	Nonce      ReplicaNonce   `json:"nonce"`
	Stamp      common.Stamp   `json:"stamp"`
	Operations Operations     `json:"ops"`
}

type Operations

type Operations struct {
	BINS *Block
	BDEL *bool
	BSET PropsDelta
	BMOV *BlockPoint
	TINS []*span.INSSpan
	TDEL []*span.DELSpan
	TFMT []*span.FMTSpan
	TMOD []*span.MODSpan
}

type Prop

type Prop struct {
	Nested map[string]Prop
	Stamp  *common.Stamp
	Value  any
}

func (*Prop) IsNotLeaf

func (prop *Prop) IsNotLeaf() bool

func (Prop) MarshalJSON

func (prop Prop) MarshalJSON() ([]byte, error)

assuming LEAF flagged nested is not used

func (*Prop) UnmarshalJSON

func (prop *Prop) UnmarshalJSON(data []byte) error

assuming LEAF flagged nested is not used

type PropDelta

type PropDelta struct {
	Nested map[string]PropDelta
	Value  any
}

func (*PropDelta) IsNotLeaf

func (prop *PropDelta) IsNotLeaf() bool

func (PropDelta) MarshalJSON

func (prop PropDelta) MarshalJSON() ([]byte, error)

assuming LEAF flagged nested is not used

func (*PropDelta) UnmarshalJSON

func (prop *PropDelta) UnmarshalJSON(data []byte) error

assuming LEAF flagged nested is not used

type Props

type Props map[string]Prop

func UpdateProps

func UpdateProps(props Props, delta PropsDelta, stamp common.Stamp) Props

assuming LEAF flagged nested is not used and delta is not nil

type PropsDelta

type PropsDelta = map[string]PropDelta

type ReplicaNonce

type ReplicaNonce []common.Nonce // []common.Nonce is a tuple of [block-nonce, text-nonce]

type Version

type Version map[common.ReplicaID]ReplicaNonce

func (Version) Add

func (v Version) Add(replicaID common.ReplicaID, nonces ReplicaNonce) bool

func (Version) IsNewerOrEqualThan

func (v Version) IsNewerOrEqualThan(other Version) bool

func (Version) IsNewerThanExceptFor

func (v Version) IsNewerThanExceptFor(other Version, replicaID common.ReplicaID) bool

func (Version) Merge

func (v Version) Merge(other Version) bool

Jump to

Keyboard shortcuts

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