repo

package
v0.0.0-...-532f3c7 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: Apache-2.0, MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ATPROTO_REPO_VERSION int64 = 3

Version of the repo data format implemented in this package

Variables

View Source
var ErrNotFound = errors.New("record not found in repository")

Functions

func CheckOp

func CheckOp(tree *mst.Tree, op *Operation) error

Does a simple "forwards" (not inversion) check of operation

func InvertOp

func InvertOp(tree *mst.Tree, op *Operation) error

Applies the inversion of the `op` to the `tree`. This mutates the tree.

Types

type Commit

type Commit struct {
	DID     string   `json:"did" cborgen:"did"`
	Version int64    `json:"version" cborgen:"version"` // currently: 3
	Prev    *cid.Cid `json:"prev" cborgen:"prev"`       // TODO: could we omitempty yet? breaks signatures I guess
	Data    cid.Cid  `json:"data" cborgen:"data"`
	Sig     []byte   `json:"sig" cborgen:"sig"`
	Rev     string   `json:"rev" cborgen:"rev"`
}

func (*Commit) MarshalCBOR

func (t *Commit) MarshalCBOR(w io.Writer) error

func (*Commit) UnmarshalCBOR

func (t *Commit) UnmarshalCBOR(r io.Reader) (err error)

func (*Commit) VerifyStructure

func (c *Commit) VerifyStructure() error

does basic checks that syntax is correct

type Operation

type Operation struct {
	Path  string
	Value *cid.Cid
	Prev  *cid.Cid
}

func ApplyOp

func ApplyOp(tree *mst.Tree, path string, val *cid.Cid) (*Operation, error)

Mutates the tree, returning a full `Operation`

func NormalizeOps

func NormalizeOps(list []Operation) ([]Operation, error)

re-orders operation list, and checks for duplicates

func ParseCommitOps

func ParseCommitOps(ops []*comatproto.SyncSubscribeRepos_RepoOp) ([]Operation, error)

func (*Operation) IsCreate

func (op *Operation) IsCreate() bool

func (*Operation) IsDelete

func (op *Operation) IsDelete() bool

func (*Operation) IsUpdate

func (op *Operation) IsUpdate() bool

type Repo

type Repo struct {
	DID    syntax.DID
	Clock  *syntax.TIDClock
	Commit *Commit

	RecordStore blockstore.Blockstore
	MST         mst.Tree
}

func LoadFromCAR

func LoadFromCAR(ctx context.Context, r io.Reader) (*Repo, error)

func NewRepo

func NewRepo(did syntax.DID) Repo

func VerifyCommitMessage

func VerifyCommitMessage(ctx context.Context, msg *comatproto.SyncSubscribeRepos_Commit) (*Repo, error)

temporary/experimental method to parse and verify a firehose commit message

func (*Repo) GetRecordBytes

func (repo *Repo) GetRecordBytes(ctx context.Context, collection syntax.NSID, rkey syntax.RecordKey) ([]byte, error)

func (*Repo) GetRecordCID

func (repo *Repo) GetRecordCID(ctx context.Context, collection syntax.NSID, rkey syntax.RecordKey) (*cid.Cid, error)

Directories

Path Synopsis
cmd
Implementation of the Merkle Search Tree (MST) data structure for atproto.
Implementation of the Merkle Search Tree (MST) data structure for atproto.

Jump to

Keyboard shortcuts

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